Skip to content

Code Examples

IanM-Matrix1 edited this page Aug 29, 2020 · 2 revisions

This is an index of the examples provided with the library.

There is no real order to reading them, but top-to-bottom would be a reasonable way to read through them.

Table of Contents

simple_loops

simple_loops/print_string_v1.asm

Very simple example of a loop contrasting a loop written in standard assembly format, and the same loop written using the structured commands.

simple_loops/print_string_v2.asm

Another example, using the structured loop commands, but also advancing the idea of making assembly a little higher level than standard assembly.

simple_loops/print_string_v3.asm

The previous examples used zero-terminated strings, while this example uses a size-prefixed string to carry out the same task and demonstrates a structured loop embedded within a structured if.

simple_loops/print_string_v4.asm

Just to fill out the set, printing strings properly. Doesn't actually demonstrate any loops.

joystick

joystick/simple_fire_down.asm

Demonstrates a simple check of the fire button on joystick port 2 using the if_key_down statement - holding the button will cycle the screen colour from white, through the greys and into black, then in reverse back to white again.

joystick/simple_fire_pressed.asm

This is pretty much the same code as simple_fire_down.asm, except it uses the if_key_pressed statement to demonstrate the one-shot behaviour of 'pressed' vs 'down'.

joystick/full_joystick_state.asm

This example provides a full breakdown of the joystick state of port 2.

It covers all of the machinery to read joystick port 2, plus every one of the if_key_down, if_key_up, if_key_pressed, if_key_not_pressed, if_key_released and if_key_not_released tests.

keyboard

keyboard/wasd_keyboard_state.asm

This is a duplicate of joystick/full_joystick_state.asm, except that it uses SPACE & the WASD keys