Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Preliminary Manual Sticky Locked

A topic by bitblitter created Sep 10, 2020 Views: 1,447
This topic is locked
Viewing posts 1 to 1
Developer (8 edits)

I'll add information to this sticky post over time in order to make it useful as a introductory manual for Micro16. So please, keep coming back here from time to time if you'd like.

M16BASIC

The embedded BASIC system employs a  compiler that outputs byte code which is then run in a VM. The compiler is at its core based on bas55 ( Copyright © 2020 Jorge Giner Cordero) which is an implementation of the ECMA-55 minimal basic standard but has been (and continues to be) extended quite a bit.

For documentation of the underlying bas55 system and a great reference manual for programming using ECMA-55 BASIC  please refer to the following link: Bas55 Documentation Page

Changes to the ecma-55 standard BASIC:

  • Variable names are not limited to A-Z[N] (N being a numeric suffix or $ ) in M16BASIC:  all identifiers have a maximum length of 48 characters and the '_' underscore character is allowed.
  • Line end comments can be used: anything following the '#' character is ignored by the compiler. Please note though that you still have to have both, a line number and the keyword REM on any pure comment lines.
  • Subroutines can be given an identifying label using the PROC keyword. Labels have to begin with '$' and otherwise fall under the general rules for identifiers.
  • use GOSUB $PROCNAME to call a labeled subroutine.
  • Text in REM comments can be any case.

M16BASIC specific additions:

  • PEEK(address) and POKE address, value can be used to directly manipulate memory.
  • VMODE N switches the display to video mode N (please refer to "Micro16 virtual computer systems for a list of modes).
  • CLS N clears the screen to the color N.
  • PAUSE N waits for N frames to be rendered before continuing (frame rate is a fixed 60 fps). This is useful for syncing graphics operations to the screen refresh to avoid tearing.
  • PRINTAT column, row sets the output position for the next PRINT statement. Note that column and row are interpreted as y,x pixel coordinates in graphics display modes.
  • INKEY returns the scan code of the key held down by the user during the current frame (or 0 if no key is being depressed).
  • PAPER N (0-7) and INK N (0-15)  set the foreground and background  color for text output.
  • POINT X,  Y, N draws a point of color N at coordinates X and Y (graphics modes only)
  • DRAWLINE X1, Y1, X2, Y2, N draws a line from point X1, Y1 to X2, Y2 using color N (graphics modes only)
  • BITBLT ImageAddress, RectX, , RectY, RectWidth, RectHeight, ImageStride, DestinationX, DestinationY copies a a rectangle of image data, as specified by the RectN parameters,  from the image located at ImageAddress to the display at DestinationX/Y. ImageStride specifies the number of bytes to skip to get from one line of the source image to the next (allows for padded scanlines) (only supported in mode 2 right now)
  • SETREG Register, Value can be used change the value of system registers.
  • LOAD Filename, Address loads a file from the current directory of the host system to the given address in memory
  • SPRITESHEET SheetID, ImageAdress, CelWidth, CelHeight, CelCount, Stride defines a "spritesheet" for the Micro16 sprite system. The first five arguments you pass in define the sheet "slot" (0-256) to be used, the memory location of the source image, the width and height and number of sprite cels included in the image (each sheet can only contain one set of cels with a common specification of dimensions). Stride defines the source image width in the same way as described under BITBLT above.
  • SPRITE SpriteID, SheetID, CelID, Xpos, Ypos sets up  a sprite slot (0-256). The arguments specify the sprite slot, the spritesheet slot used by the sprite, the cel inside the sheet and the output X and Y coordinates of the sprite's upper left corner. Note that the coordinates can be negative or exceed the display borders in order to be able to move sprites in/out of the display seamlessly.
  • ANIMATION AnimID, SpriteID,  StartCel, CelCount, FPS adds an animator to a sprite that cycles through cels StartCel to StartCel + CelCount - 1 at the given frame rate.


System Variables and Registers

System variables are fixed memory locations inside the system page (the first 16 KB or memory). The system stores various bits of state information here and some of the system variables can be changed by user programs (using POKE). Similarly the machine registers can be used to make certain settings related to various subsystems, or "virtual chips" of the IMachine. Registers are limited in number and generally only used for states that require very fast access (registers are much faster than system variables)


Micro16 virtual computer systems

  • Byte code processor VM serves as "CPU". This runs, together with the console, in a separate thread from the IMachine (which provides all the emulated hardware) at the full speed that the host computer is capable of (no artificial virtual processor speed limits are employed).
  • 1 MB of ram of which the first 16 KB are reserved by the system and another block of 128 KB is designated as video memory.
  • The IMachine's virtual graphics chip supports three different resolutions
    • (0) 80x30 character mode with 8 PAPER (background) and 15 INK  (foreground) colors plus inverse video.
    • (1) 640x480 pixels monochrome graphics
    • (2) 320x240x256 indexed color graphics. Palette is 256x24 bits RGB.
    • (3) 640x480x16 indexed color graphics (not implemented yet).
  • The graphics system has support for fast "hardware" image data copying (bitblit) and includes a sprite system with animation support.