Author Topic: ChipmonkeyLua v1.0  (Read 7859 times)

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
ChipmonkeyLua v1.0
« on: December 29, 2013, 03:01:05 PM »
After CMBASIC, here's CMLua which is further developed now. All binaries are in one ZIP, too:
http://egsl.retrogamecoding.org/media/chipmonkey/CMLua.zip

Examples are included and as usual a few screenshots:



Tomaaz

  • Guest
Re: ChipmonkeyLua v1.0
« Reply #1 on: December 29, 2013, 11:45:33 PM »
Well, I wasn't sure about this project but it turned up pretty cool. I can't see what else could be done if we're talking about old-school interpreter. Well done!  ;)

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #2 on: December 30, 2013, 09:07:40 PM »
Thanks. BTW I forgot two examples.
plasma.lua:
Code: [Select]
--' my favourite plasma demo
--' ported from smallbasic to yabasic to lua
--' by cybermonkey

cls()
cols={}
  cols[0]={}
  cols[1]={}
  cols[2]={}
 
for i=0,255 do
  cols[0][i]= math.abs(128 - 127 * math.sin(i * math.pi / 32))
  cols[1][i]= math.abs(128 - 127 * math.sin(i * math.pi/ 64))
  cols[2][i]= math.abs(128 - 127 * math.sin(i * math.pi / 128))
  end


for y = 1,480 do
   for x =1,639 do
      c = int((math.sin(x/35)*128+math.sin(y/28)*32 + math.sin((x+y)/16)*64))

     if c >255 then
      c = c - 256
     end
     if c < 0 then
      c = 256 + c
      end

      r = cols[0][c]
 
      if r > 255 then
r = r - 256
      end
      if r < 0 then
r = 256 + c
      end
      g = cols[1][c]

      if g >255 then
g = g - 256
      end
      if g < 0 then
g = 256 + c
      end
      b = cols[2][c]
      if b>255 then
b = b - 256
      end
      if b < 0 then
b = 256 + c
      end
     
      ink ( hrgb (r, g, b))
      pset (x, y)

    end
end

ink (hrgb (0,200,200))
locate (0,30,"")

And lorenz.lua (from bp.org):
Code: [Select]
paper (0)
cls()
x=0
y=20
z=20
count=0
tick = gettickcount()
while  not keypressed() do
  xx = x + 0.01 * ( -10.0 * x + 10.0 * y)
  yy = y + 0.01 * (  28.0 * x - y - x * z )
  zz = z + 0.01 * ( -8.0  * z / 3.0  + x * y )
 
  ink  (hrgb(int(rnd()*255),int(rnd()*255),int(rnd()*255)))
  line (x*10+320, -z*10+500, xx*10+320, -zz*10+500)
  x = xx
  y = yy
  z = zz
  count = count + 1
  if count>=20000 then
    break
  end
end
tack = gettickcount()
tock = (tack-tick)/1000
ink (hrgb (255,255,255))
locate (0,30,"")
print ("TIME: ".. tock .. " SECONDS")
print (count.. " LINES DRAWN")

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #3 on: January 03, 2014, 10:18:27 PM »
I made a temporarily website out of the documentation: http://cmb.retrogamecoding.org/

Tomaaz

  • Guest
Re: ChipmonkeyLua v1.0
« Reply #4 on: January 09, 2014, 07:34:26 PM »
There is one problem on Linux. Only exit() closes the program properly. When you try to close the window, it disappears, but ChipmonkeyLua is still running in the background. This is annoying when using external editor. After some time you may end with several ChipmonkeyLua processes running in the background and eating your memory and all you can do is kill them manually.

EDIT: Would it be possible to compile ChipmonkeyLua on Raspberry Pi?
« Last Edit: January 09, 2014, 07:36:29 PM by Tomaaz »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #5 on: January 09, 2014, 08:13:23 PM »
There is one problem on Linux. Only exit() closes the program properly. When you try to close the window, it disappears, but ChipmonkeyLua is still running in the background. This is annoying when using external editor. After some time you may end with several ChipmonkeyLua processes running in the background and eating your memory and all you can do is kill them manually.

EDIT: Would it be possible to compile ChipmonkeyLua on Raspberry Pi?
I know of this problem. It's the same on Windows, too. I will take a look into it but found no solution, yet. It should be possible to compile CMLua on a RaspPi, I might try it in the emulator myself the next days ...

igamealot

  • Guest
Re: ChipmonkeyLua v1.0
« Reply #6 on: January 13, 2014, 06:43:29 AM »
This is pretty icky first time I try it.
I really like some of it and I love the concept.
But it feels not so user friendly.

help() is a nice command, should be a suggestion under the startup system info.
Could use some functional arguments like number of columns to put the
help list into tabs, or a character or string to filter the commands.

The strange editing behavior could be alleviated if we could paste into the editor.

The line numbering is too strict, is there goto and gosub? No?
Then there really is no need for numbers, except if they are for debugging errors at line n.
You'd be better off with label system than strict line numbers.
I'm looking at OpenBasic as my new love like Lua.
Check out how it handles its label/line numbers, pretty nice. Its very much like old basic

10 x$=inkey$: if x$ = "" then goto 10
becomes
10
    x$=inkey$
    if x$= "" then goto 10

Wish I had that in 1983, and every time i have to convert BASIC programs.
Of course Open Basic doesn't have inkey$ command! neither does MY-BASIC which is used inside of Ascii Hero Go
It's always something.

anyway.

edit() should maybe open a default text editor, maybe you can configure edit's options
with a parameter like edit('config')

You could probably remove some commands.
For instance fillrectangle() was done in Extended Basic like so

Code: [Select]
Line(x1,y1)-(x2,y2),linecolor,linesize,pattern,fillcolor,patternPattern at the end was some hex values that made textures inside the fill and thus a million scrolling games were born, in assembly.I only managed to make scrambled gibberish in those patterns.
You could of course make the pattern some reference to a string of ascii characters or an image file or something.

clear() doesn't clear the screen, should be cls() anyway, that's still used in windows console after 30 years.

Would love to be able to customize the whole UI and language for this thing.
 How deep is the source? It's mostly Lua?

I recently posted the Aquarius Guide To Home Computing and Aquarius Home Computer System Extended Microsoft Basic Cartridge Instructions to archive.org.

Get the Virtual Aquarius emulator for windows for the experience of a lifetime ago.

Think you can fork Chipmonkey Aquarius?
Ideally it could be just some config files and scripts yeah?

Boot Loader BASIC has some new for 2014 commands on the Virtual Aquarius (30 years for a new BASIC wooo).
Like Joy() command you need in your life!

It also saves binary ROM files, kinda like luac I suppose.
Maybe you need some routine for self contained executable compiler.
A command like Boot Loader BASIC LDUMP. Ain't that an attractive command?

Keep up the awesome.



« Last Edit: January 13, 2014, 08:02:36 AM by igamealot »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #7 on: January 13, 2014, 08:45:25 AM »
Line numbers are only for editing purposes. If you load the script into an external editor (I suggest Geany) you'll see that there are no line numbers saved. It's needed for lineedit (line number) to change a line.
It's retro and therefore user friendly as back in the 1980s.  ;)
The source code is 100% Free Pascal (using the units ptcgraph, ptccrt and ptcmouse) but it will not be released, yet.
clear() clears the graphics, cls() clears the whole screen. Try it: circle (400,300,300). Then clear(), you should still see the text but no circle.
« Last Edit: January 13, 2014, 08:58:03 AM by Cybermonkey »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #8 on: January 23, 2014, 09:17:26 AM »
There is one problem on Linux. Only exit() closes the program properly. When you try to close the window, it disappears, but ChipmonkeyLua is still running in the background. This is annoying when using external editor. After some time you may end with several ChipmonkeyLua processes running in the background and eating your memory and all you can do is kill them manually.

EDIT: Would it be possible to compile ChipmonkeyLua on Raspberry Pi?
In the next version the exit() function is working in scripts, too. So it is possible to e.g. do the following
Code: [Select]
...script...
inkey()
exit()

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #9 on: February 01, 2014, 07:58:57 PM »
Okay guys the next version is online. It's available on the usual site: http://cmb.retrogamecoding.org/ and all binaries are again in one ZIP.

Changelog:
  • added triangle, filltriangle
  • activepage and visualpage for a second screen/backbuffer
  • added a yahtzee example
  • changed some examples to work with activepage/visualpage

Tomaaz

  • Guest
Re: ChipmonkeyLua v1.0
« Reply #10 on: February 02, 2014, 11:47:55 AM »
Cool.  8) I know it's not your main project, but would it be possible to add two features to it? Possibility to get the color of a pixel and an option that saves a screen content to the file?

BTW What did you use to make the website? I like its simplicity and colors.

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #11 on: February 02, 2014, 12:07:00 PM »
I will look into that. Retrieving a pixel colour won't much of a problem I guess, the other thing ... let's see.
Believe it or not, the page is done with pandoc (mark down language) -  (http://johnmacfarlane.net/pandoc/) - should be available in any newer Linux distro. This is my CSS (it's also in the download in documentation folder):
Code: [Select]
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700);

html {
    color:#FFFFFF;
    background:#222222;
}

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td {
    margin:0;
    padding:0;
    color:#FFFFFF;
}

table {
    border-spacing:0;
    font-size:inherit;
    font:100%;
    max-width:100%;
    background-color:transparent;
    border:1px solid #DDD;
    border-left:0;
    border-collapse:collapsed;
    -webkit-border-radius:4px;
    -moz-border-radius:4px;
    border-radius:4px;
}

fieldset,img {
    border:0;
}

address,caption,cite,code,dfn,em,strong,th,var {
    font-style:normal;
    font-weight:400;
}

ol,ul {
    list-style:none;
}

caption,th {
    text-align:left;
}

h1,h2,h3,h4,h5,h6 {
    font-size:100%;
    font-weight:400;
    color:#20639b;
    margin:1em 0;
}

q:before,q:after {
    content:'';
}

abbr,acronym {
    border:0;
    font-variant:normal;
    border-bottom:1px dotted #000;
    cursor:help;
}

sup {
    vertical-align:text-top;
}

sub {
    vertical-align:text-bottom;
}

input,textarea,select {
    font-family:inherit;
    font-weight:inherit;
    font-size:100%;
}

legend {
    color:#000;
}

h1,h2,h3,h4,h5,h6,strong {
    font-weight:700;
}

em {
    font-style:italic;
}

blockquote,ul,ol,dl {
    margin:1em;
}

ol,ul,dl {
    margin-left:2em;
}

ol {
    list-style:decimal outside;
}

ul {
    list-style:disc outside;
}

dl dd {
    margin-left:1em;
}

th,td {
    line-height:1.125em;
    text-align:left;
    vertical-align:top;
    border-top:1px solid #DDD;
    border-left:1px solid #DDD;
    padding:.5em;
}

th {
    font-weight:700;
    text-align:center;
    color:#20639b;
}

table thead:first-child tr:first-child th,table tbody:first-child tr:first-child th,table tbody:first-child tr:first-child td {
    border-top:0;
}

table thead:first-child tr:first-child th:first-child,table tbody:first-child tr:first-child td:first-child {
    -webkit-border-radius:4px 0 0 0;
    -moz-border-radius:4px 0 0;
    border-radius:4px 0 0 0;
}

table thead:first-child tr:first-child th:last-child,table tbody:first-child tr:first-child td:last-child {
    -webkit-border-radius:0 4px 0 0;
    -moz-border-radius:0 4px 0 0;
    border-radius:0 4px 0 0;
}

table thead:last-child tr:last-child th:first-child,table tbody:last-child tr:last-child td:first-child {
    -webkit-border-radius:0 0 0 4px;
    -moz-border-radius:0 0 0 4px;
    border-radius:0 0 0 4px;
}

table thead:last-child tr:last-child th:last-child,table tbody:last-child tr:last-child td:last-child {
    -webkit-border-radius:0 0 4px 0;
    -moz-border-radius:0 0 4px;
    border-radius:0 0 4px 0;
}

table tbody tr:nth-child(odd) td,table tbody tr:nth-child(odd) th {
    background-color:#f9f9f9;
}

caption {
    margin-bottom:.5em;
    text-align:center;
}

p,fieldset,table,pre {
    margin-top:.5em;
    margin-bottom:.5em;
}

body {
    font:16px/1.4 "Helvetica Neue", Helvetica, "Open Sans", Arial, sans-serif;
    color:#333;
    max-width:960px;
    margin:0 auto;
}

pre,code,kbd,samp,tt {
    font-family:monospace;
    font-weight: bold;
    line-height:100%;
}

h1 {
    font-size:200%;
    border-bottom:1px dotted #ddd;
}

a,a:visited,code {
    color:#f06024;
}

h2 {
    font-size:160%;
}

h3 {
    font-size:120%;
}

h4 {
    font-size:110%;
}

h5 {
    font-size:95%;
}

h6 {
    font-size:90%;
    color:#999;
}

dl {
    margin:0 0 1.125em;
}

dt {
    font-weight:700;
    line-height:1.125em;
}The

dd {
    margin-left:1em;
    line-height:1.125em;
}

pre,blockquote {
    border:1px solid #ddd;
    background-color:#f1f1f1;
    -webkit-border-radius:6px;
    -moz-border-radius:6px;
    border-radius:6px;
    padding:10px;
}

blockquote {
    margin:1em 2.5em;
}

code {
    color:#000000;
    background:#f1f1f1;
}

img {
    max-width:100%;
}

ol[type=1] {
    list-style-type:decimal;
}

ol[type=a] {
    list-style-type:lower-alpha;
}

ol[type=A] {
    list-style-type:upper-alpha;
}

ol[type=I] {
    list-style-type:upper-roman;
}

ol[type=i] {
    list-style-type:lower-roman;
}

a:link {
text-decoration: none;
text-underline: none;
 
}

a:hover {
  text-decoration: underline; }
and my makedoku script:
Code: [Select]
pandoc -s -S --toc -c full.css documentation.md -o documentation.html
Weird enough is that I have more fun developing CMLua and scripting in CMLua. (Developing the Yahtzee clone was a lot of fun!)

Tomaaz

  • Guest
Re: ChipmonkeyLua v1.0
« Reply #12 on: February 02, 2014, 12:33:20 PM »
I will look into that. Retrieving a pixel colour won't much of a problem I guess, the other thing ... let's see.

That will do. If I get access to the colors, I could write in CMLua itself a function that saves the screen to .ppm file.

Believe it or not, the page is done with pandoc (mark down language)...

Thanx! :) I will definitely have a look at it.

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: ChipmonkeyLua v1.0
« Reply #13 on: February 02, 2014, 12:34:57 PM »
Well, I can get a colour but only its 16bit integer value. I am looking for a function which converts the integer to its RGB values.