User Tools

Site Tools


notes:spring2025:projects:mtb0

This is an old revision of the document!


MTB0

NOTE: this is a collaborative document between a couple of my classes this semester. That means more people editing. Be mindful that only one person can edit the document at a time.

Only task headings have been provided. You are not expected to know how to do the task given by just that description (although in some cases it can be adequately figured out). Instead, if no further information is yet present, ASK FOR DETAILS on the discord, then contribute that clarity here.

If something is present but needs polish: spruce it up.

If something is present but is incorrect: please fix it.

This is intended to be an informative, useful document that all can benefit from.

Those with prior experience, please be mindful not to gobble up all the low-hanging fruit from the newcomers.

Design your sprites / custom texture

Specifying Texture in XML

To get any textures into your cartridge other than the BIOS texture, you will need to add them into your .xml file
Adding textures will always follow the pattern of:

<textures>
    <texture path="FILENAME0.vtex" />
    <texture path="FILENAME1.vtex" />
    <texture path="FILENAME2.vtex" />
    ...
    <texture path="FILENAMEX.vtex" />
</textures>

When you go to use these textures in your code, the texture_id will follow the order of where they are in the xml, ie FILENAME0.vtex will have the texture_id 0
Note: In your directory you will have png files, not vtex, as they are an intermediate step between the files and the cartridge, so if you have 0_FirstImage.png, the xml will be:

<texture path="0_FirstImage.vtex" />

Selecting Texture

Vircon32 has built in functionality for working with any textures specified in the xml
To draw anything to the screen you need a few things:

  • Texture
  • Region
  • Location

The easiest portion to set up is the texture, as you only need the command

select_texture(texture_id);

where texture_id is the id of the texture you are using, which is determined by its position in the xml file

Defining Region

The next step to drawing a sprite to the screen is selecting the region of the texture you want to use.

Because regions are specified portions of a texture, you can use many commands to define them in different ways, however, all of the commands will follow a similar structure

The simplest command you can use is define_region_center(), which follows the structure:

define_region_center(min_x, min_y, max_x, max_y );

Where each argument corresponds to a coordinate on the .png file, that together draw a box containing your region.

As stated above, this command is not the only one, so you should also try experimenting with some of the others, which can be found in the C API reference on the Vircon32 website

Specifically this section:https://www.vircon32.com/api/video.html#Definition%20of%20texture%20regions

Selecting Region

It is simple to select a region. Use the command select_region() and pass the identifier of that region, ie, select_region(0);

If you need more help visualizing the region process, the software provided by the creator of vircon32, linked below, can help. It visualizes the Region selection within an image and can even generate a header file for automation! https://github.com/vircon32/ComputerSoftware/releases/tag/regioneditor-v25.1.6

Check for keypresses

Selecting joystick

Reading joystick value

translating read joystick value into X and Y

Playfield bounds checking

Vircon32 screen resolution

How to check if our sprite has reached a bound

How to limit our sprite from leaving the playfield

How to cause our sprite to wrap-around on the playfield

notes/spring2025/projects/mtb0.1739222723.txt.gz · Last modified: 2025/02/10 21:25 by tstrickl