Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Amos 1.3 to PC, Mac, Android... in the summer 2019  (Read 12239 times)

0 Members and 1 Guest are viewing this topic.

Mikket

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 4
  • Generic Amiga User
Amos 1.3 to PC, Mac, Android... in the summer 2019
« on: January 28, 2019, 06:18:07 PM »

Amiga Amos programs will run in most platforms next summer (fingers crossed)!


I put the latest readme from the Amos2 here.
 Go and support Francois !
Mikko
-----------------------------------------------------------------------------------


# AMOS 2 Compiler version 0.1 - 28/01/2019
## *By Francois Lionet - francois@francoislio.net*

## **Welcome to the second version of the AMOS 2 Compiler!**

A lot of work done this week.

- Shared and Global keywords, allowing you to control how procedures deal with variables
- Dim, single and multidimensional arrays
- Data, Read, Restore
- Proper keyboard handling. You now end a program by pressing the classic CONTROL-C
- Inkey$: keycodes are converted to the Amiga equivalent to be compatible
- Mouse handling. X Mouse and Y Mouse as functions (you cannot set the position of the mouse for the moment)
- Change Mouse, Show, Show on, Hide, Hide on, Mouse Key, Mouse Click
- Error messages and error management in the running application. You now get proper 'Illegal function call' errors when you call a function with improper parameters
- Math function: Sgn, Abs, Int, PI#, Min, Max, Sin, Cos, Tan, Asin, Acos, Atan, Sqr, Log, Exp (not tested :) - still to do: Hsin, Hcos, HTan (trigonometrical functions only in degrees for the moment)
- Graphic functions: Plot, Draw, Draw to, Circle, Ellipse, Bar, Box, Gr Locate, =Xgr, = Ygr, Ink (but for the pattern parameter),
- New option (set as default in this version) to include the line number of each instruction in the compiled application, allowing proper runtime errors reporting (like 'Illegal function call error at line 10 column 5)

To sum up:
- Compiler -> 95% done
- Control instruction (like For/Next - If/Then etc) -> 100% done
- Procedures -> 100% done
- Error management (on error goto / on error proc / error reporting) -> 100% done
- Keyboard and mouse -> 50% done
- Graphic functions -> 75% done (still Paint and patterns to do)
- Text windows -> 50% done
- Mathematical functions -> 80% done
- String functions -> 75% done

The Helloworld application included in this folder contains a little (very little, please make some more impressive) demo of the new graphical and math functions.

AMOS 2 is taking shape nicely. Most of the work on the compiler itself is done, adding new instructions or function is a matter of minutes, I can concertrate on the runtime library that makes the program work.

My plan for the week to come:

- Finish the graphical instructions, implement graphic fonts
- Finish the remaining mathematical functions
- Complete the text Windows (Wind Open, Wind Close etc), find a better default font
- Implement Pixi.js as a renderer

If I manage to keep on this pace, I see Sprites, Bobs and AMAL completed at the end of February (can't wait to program AMAL, gonna be a lot of fun in Javascript!)... And we will be able to program the first real games in AMOS 2!

See you next week!

Francois


## Executables
You will find the executable version of the compiler at: https://drive.google.com/drive/folders/189QBsS_Py9TUWE4jfacxpkuwjQ4j1TBU?usp=sharing

- amosc-win.exe -> for Windows
- amosc-linux -> for Linux
- amosc-macos -> for MacOS

Yeah I know, these files are quite big. I will try to find another package maker for node. Anyway, they launch real quick. Copy the file at the root of the 'amos-2' directory.

## Try it!
This directory contains a Hello world application in the 'application' folder. To try the compiler, open a command line window, go in the directory where the compiler is located (normally the root of the 'amos-2' directory), and type:

amosc-win.exe ./applications/helloworld

You should obtain a message:
'Compilation successful.'

Now open a explorer, and look inside of the 'applications/helloworld' folder. You will find a 'html' folder that contains the compiled application ready to be launched, the entry point being the file 'index.html'. To launch this application, open your browser and type the full path to the index.html file in the address bar. The application should be displayed in your browser!

## What is done today?

- the compiler
- variables
- arrays, dim
- procedure / end proc / shared / global
- for / next / step
- repeat / until
- while / wend
- do / loop
- exit / exit NUMBER / exit if
- if / then / else / endif (else if still to be done)
- on NUMBER goto / gosub / proc
- on error goto / proc
- resume / resume LABEL / resume next / resume label
- goto / labels
- gosub / return
- errors in runtime
- locate
- clw
- home
- print
- left$ / mid$ / right$
- chr$
- space$
- upper$
- lower$
- val
- len
- tab$
- pen
- paper
- centre
- border (has no effect yet)
- writing
- title top / bottom (no effect yet)
- under on / off
- scroll on / off
- scroll
- cup / cdown / cleft / cright /note that the cursor is not yet visible)
- memorize x / y
- hscroll / vscroll
- set tab
- gr locate
- plot
- draw, draw to
- circle, ellipse
- bar, box
- ink
- xgr, ygr
- abs, int, sgn
- sin, cos, tan
- asin, acos, atan
- log, exp
- sqrt
- inkey$
- change mouse, x mouse, y mouse, mouse key, mouse click


## Create your own AMOS 2 application

To create your own AMOS 2 application, follow the steps:

- copy the 'helloworld' folder into another folder in the 'applications' directory
- rename 'helloworld.amos' to 'myprogram.amos'
- open your favorite source code editor
- load the file 'manifest.hjson', it contains the default definition of the program. Change the section 'infos/start' and enter the name of your .amos file. You can also change the default screen size and color. The 'display' section contains the definition of the main canvas element that will contain the display. These information are copied into the 'index.html' file when compiling. Note the 'zoomX' and 'zoomY' values: they are mandatory to scale the default AMOS red screen (320 x 200) into a size that is compatible with today's resolution. I have not yet worked on full screen, it will come in the future.
- load the file 'myprogram.amos' and type your code! Please note that this is the very first public version of the compiler, I have not tested real code. Please consider it as a toy for you to play with, with simple code.
- Unlike the original AMOS, the names of the variable IS case-sensitive. So a variable name 'hello' will not be the same as 'Hello'. I think I will put that as an option for compilation.

Of course, in the future, you will be able to create a new application with a simple command:

amosc -new myprogram.amos ... and it will copy the manifest and create the proper folders.

## Note on the code produced

Once you have compiled a program, you will find the code in the file 'application.js' in the 'myapplication/html/run' folder. You might be surprised by the code produced, and how it is sliced in blocks. It is the only way to proceed to port a language such as Basic into Javascript. Javascript does not allow endless loops or gotos, so the program must be run 'from above' and control on the execution must be possible at each time.
- first to avoid taking all the processor time, and render Chrome inoperant.
- second to allow goto and error catching the Basic way, with On Error Goto...

### The compiler has for the moment two way of producing code.

- 'fast' code: if your program do not contain any 'On Error', the Javascript instructions are grouped as much as possible, and the number of block is reduced.
- 'slow' mode: if an 'On Error' instruction has been detected in the first pass of compilation, the compiler will produce one block of code per instruction. It is the only way to allow 'Resume' and 'Resume Next'. Such mode wuill be slower, I still have to do some benchmarking.

### Where is the main loop?

The code that calls all the blocks contained in 'application.js' can be seen in the file 'runtime/amos.js'. You will see that the loop is verfy simple and no time is lost between calling each block of code. You will also see that I artificially slow down the execution.

### About the speed of execution:

I am sure that many of you will try to have an idea of the speed of the code produced. And you will be deceived as I artificially slow down the execution to avoid cluttering Chrome. Here too, experimentation must be done to find the best setting that will at the same time allow the program to run at maximum speed without putting the user's machine in danger.
Anyway, my first goal is to allow native Amiga AMOS programs to run, and I am sure that I will have to slow down the code even further to achieve compatibility. We will see!

### In the future

I will make a 'fastest' mode that will NOT cut the code into blocks, or only the minimum. The code produced will be then pure Javascript and the speed of execution will be comparable to the speed of real Javascript.

I will also implement the possibility to insert real Javascript code in the middle of the Basic code, for time-critical sections. Example:

```
Procedure GoFast[ A, B ]
    {
        // We are in Javascript now!
        this.retValue = 0;                              // This variable will be accessible in Basic
        for ( var x = 0; x < 100000; x++ )
        {
            this.retValue += this.pA * this.pB;         // Stupid example, but shows how to get the variables.
        }   
    }
    ' Back to Basic!
    Param retValue                                      ' Return the variable defined int he Javascript portion
End Proc
```

## Please help and share!

Although it is a very early version, any report on things that are supposed to work and don't is welcomed. Just post your comments on Patreon.

Please share!

I am doing this project alone on my free time. It is a big project, and any support on Patreon is more than welcomed. I do not post on Facebook anymore to save time (a lot of time saved since I stopped going there), so you are the ONLY people who can make this project popular and help increase the number olf Patrons. Plkease share such posts in the Amiga forums on FB, on your page... everywhere you can!

And if you are not yet one of my Patrons, you are welcomed to help: www.patreon.com/francoislionet

All for today! See you next week for a new version. Until then I will post my progress day by day in my thread.

Francois
« Last Edit: January 28, 2019, 09:33:43 PM by Mikket »
Logged

DarkN3mo

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 16
  • Generic Amiga User
Re: Amos 1.3 to PC, Mac, Android... in the summer 2019
« Reply #1 on: June 26, 2023, 04:28:22 AM »

snif, link dead
Logged
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022