artemis

A Fantasy Microcomputer

This project is maintained by JiFish

Artemis and Python

You can write your programs for Artemis using the python language. This is an easier and more modern way to develop your program.

This documentation is not intended to be a python tutorial. Instead it will instruct those who are already familiar with python on what features are available.

Run python scripts using the PY command on the main interface. e.g.

> PY "MYPROGRAM.PY"

Builtins

Most of the standard builtins are provided with a few differences:

import

Is not available due to sandboxing. The math and random modules have already been imported for you.

open()

The file parameter must conform to artemis’ filename standard, or an exception will be thrown. This means you can only open files on the currently mounted artemis ‘disk’, no subdirectories. Filenames are limited to alphanumeric characters, and a single optional extension after a period “.”.

print()

The file parameter is ignored. Print will always output to artemis’ screen

quit() and exit()

Are not available.

Artemis functions

The following additional functions are available to help you control Artemis.

Screen module

Screen functions are accessed via screen, e.g. screen.cls().

Available modes:

Mode Characters Colors Pixel shape Notes
0 20 x 25 32 2 x 1  
1 40 x 25 8 1 x 1 Default
2 80 x 25 4 1 x 2  
3 80 x 50 2 1 x 1  
4 40 x 50 4 2 x 1  
5 24 x 15 32 1 x 1  
6 16 x 10 125 1 x 1  

Direct screen access

Direct access to the screen cells is provided via the screen.screen object, which contains a ScreenCell object for each cell. You can access cells with their Index, which starts with 0 at the top left of the screen. The total number of cells is determined by the current screen mode. screen.screen can be iterated.

Don’t hold on to the returned ScreenCell objects as they may become stale.

ScreenCell Objects

Each ScreenCell contains the character, foreground and background colors for that cell.

Attributes

Finally, if you attempt to set a screen.screen index directly, instead the value will be passed in to the ScreenCell’s set function. See the example below.

# Four ways to set a ScreenCell
scr = screen.screen

# Using Attributes
scr[0].character = 65
scr[0].foreground = 1
scr[0].background = 0

# Using Indexes
scr[0][0] = 65
scr[0][1] = 1
scr[0][2] = 0

# Using set function
scr[0].set((65, 1, 0))

# Directly assigning to screen
scr[0] = (65, 1, 0)
# Iterate the screen and count cells with background color 0
count = 0
for cell in screen.screen:
    if cell.background == 0:
        count += 1
print("{} cells had background 0".format(count))
# Move all the screen cells forward one place
scr = screen.screen
for i in range(len(scr)-1,0,-1):
    scr[i].set(scr[i-1])

Sound module

Sound functions are accessed via sound. e.g. sound.stop()