uxn/doc/varvara.md

3.2 KiB

Varvara

Varvara is a personal computer, using the uxn instruction set, programmed in tal

UXN presents 16 I/O ports via the DEI and DEO instructions. Each port consists of 16 words of memory, and has its own I/O memory mapping behavior. Note that while other memory read and write instructions can interface with port memory, only DEI and DEO will trigger port effects.

The Varvara computer presents the following canonical port mappings -

  • 0x0, System device
  • 0x1, Console device (text output)
  • 0x2, Screen device (bitmap output)
  • 0x3, Audio device (audio0)
  • 0x4, Audio device (audio1)
  • 0x5, Audio device (audio2)
  • 0x6, Audio device (audio3)
  • 0x7, Unused
  • 0x8, D-pad controller
  • 0x9, Mouse
  • 0xA, File (file0)
  • 0xB, File (file1)
  • 0xC, Datetime
  • 0xD, Unused
  • 0xE, Unused
  • 0xF, Unused
|00 @System     &vector $2 &wst      $1 &rst    $1 &eaddr  $2 &ecode  $1 &pad     $1 &r       $2 &g      $2 &b     $2 &debug  $1 &halt $1
|10 @Console    &vector $2 &read     $1 &pad    $5 &write  $1 &error  $1
|20 @Screen     &vector $2 &width    $2 &height $2 &auto   $1 &pad    $1 &x       $2 &y       $2 &addr   $2 &pixel $1 &sprite $1
|30 @Audio0     &vector $2 &position $2 &output $1 &pad    $3 &adsr   $2 &length  $2 &addr    $2 &volume $1 &pitch $1
|40 @Audio1     &vector $2 &position $2 &output $1 &pad    $3 &adsr   $2 &length  $2 &addr    $2 &volume $1 &pitch $1
|50 @Audio2     &vector $2 &position $2 &output $1 &pad    $3 &adsr   $2 &length  $2 &addr    $2 &volume $1 &pitch $1
|60 @Audio3     &vector $2 &position $2 &output $1 &pad    $3 &adsr   $2 &length  $2 &addr    $2 &volume $1 &pitch $1
|80 @Controller &vector $2 &button   $1 &key    $1 &func   $1
|90 @Mouse      &vector $2 &x        $2 &y      $2 &state  $1 &pad    $3 &scrollx $2 &scrolly $2
|a0 @File0      &vector $2 &success  $2 &stat   $2 &delete $1 &append $1 &name    $2 &length  $2 &read   $2 &write $2
|b0 @File1      &vector $2 &success  $2 &stat   $2 &delete $1 &append $1 &name    $2 &length  $2 &read   $2 &write $2
|c0 @DateTime   &year   $2 &month    $1 &day    $1 &hour   $1 &minute $1 &second  $1 &dotw    $1 &doty   $2 &isdst $1

Varvara executes a program starting at 0x0100 until the BRK instruction occurs. BRK does not halt the machine (that would be %halt { #01 LIT .System/halt DIO }). Instead it signals that the present 'thread' of execution has completed, and returns control so that an interrupt handler can occur. The main or initialization program must register interrupt handlers before BRK.

Varvara provides 'interrupt' based I/O. The 'vector' of a given device is a program point. That point will be invoked with no stack arguments when an event on the device occurs. Interrupt handlers execute until they terminate using the BRK instruction. Varvara enqueues interrupts and will not fire another until the one under execution has completed.

The screen device's vector is a clock which ticks at 60hz. The mouse device's vector likewise fires when a mouse event such as movement or a button press occurs. The controller device similarly fires on input changes.

themes