User Tools

Site Tools


notes:comporg

This is an old revision of the document!


Computer Organization Course Notes Page

Course Notes Wiki


This is a space for members of the Computer Organization class to create a source of information reflective and assisting to the course.

Aside from assignments that may have you specifically perform operations here, you should contribute when you encounter any of the following:

  • Some neat bit of information related to the class
  • Some clarification or understanding you've had with respect to concepts in the class
  • Organizational/style improvements to existing content
  • Questions you have that may deserve a more visual answer

Working with Memory in TIC80

Persistent Memory

In order to change part of persistent memory, the process begins as normal for any other piece of memory - `poke(addr, data, size)`. However, making persistent changes to the cart is a special case - since the cart is loaded into RAM (virtually and in reality) when it is run, changes made to its memory will only apply as long as it is being run, meaning something else needs to happen in order to, say, make a visual change to the editor. After making a change to the cart, the `sync()` function must be called, specifically `sync(0, 0, true)`, which breaks down into: sync(sector bitmask, bank, tocart) - in our case, sync all (0) sectors to bank zero (0), and apply the changes to the cart (true).

TIC80 System Variables

By using peek/poke, it is actually possible to make rather large global changes to both your program itself and the way it is run. Below are some examples.

0x3FF9: DrawX 0 point. By adjusting the data stored here, it is possible to change TIC80's understanding of “0” on the x axis as it draws to the screen. This means that if you set this to 120, for example, your program's visual elements would be shifted 120 pixels to the right on every frame.

0x3FFA: DrawY 0 point. By adjusting the data stored here, it is possible to change TIC80's understanding of “0” on the y axis, similar to the DrawX 0 point. Setting this to 60, for example, would shift every frame down 60 pixels.

Other

If you're working with JS, remember that when you go to grab a constant from a library (say, pi from Math), if you forget to capitalize `Math.PI` and instead write `Math.pi` or `Math.Pi`, it will read the non-existent field without any runtime error, and instead treat it as 0. This can produce some frustratingly low-flying bugs, especially when working with games that have vector physics.

TIC-80

Projects/Games

notes/comporg.1644471335.txt.gz · Last modified: 2022/02/10 00:35 by smalik3