VB Animation

Author:
Alberto Covarrubias

Index
Concepts
Using Objs
Control Animation

Example
The Croach
In game programming, the animation is a fundamental concept that makes the difference between a game with the ultimate graphical experience and another game on the list. The animation requires special care in both, graphical design and graphical programming. This document will not cover the design of graphics, instead we will make an approach on the animation graphic programming on Virtual Boy.

Before talking about animation, you must refer to the previous document about Handling Display to have some background in VB concepts. Assuming a little knowledge in game programming we suppose that you know some graphic terms but let's define some terms used on this document.

Concepts

Interrupt: As it name says, the interrupt of CPU operation to execute a routine defined in an Address Vector. The Virtual Boy has interrupts for Controller, Timer, Ext Port, Link Port, and Video Retrace.

VIP Regs: A set of values in RAM to define the console display enviroment, like brightness, palettes, OBJs, and display status.

This few concepts will help me to explain all the following information.

Using Objects

In the previous document we found that the OBJ structure is used in Virtual Boy to display sprites. This structure is useful to define a set of chars that in different ways represent this sprites according to the order defined when you read it. Every OBJ looks like this.

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Jx

LON RON Jp
Jy
Palett Hflip Vflip 0 Char

The (Jx,Jy) is the coordinate where this char will be displayed. The LON and RON allows you define if this char will be displayed on the right-eye, left-eye or both, the paralax is used for the 3D effects. The other fields are the same as BGMAPs explained before. As you can see, this scheme lets you define some nice effects on VB. like display an object just in one led, move objects in 3D, etc. Remember that OBJs are defined to be displayed in the World structure using the BGMValue = 3.

The VB knows which OBJs will be displayed using the VIP values named SPT0, SPT1, SPT2 and SPT3. Each value represent a pointer to the initial OBJ and final OBJ to be displayed, starting with SPT3, that means, when you define the first OBJWorld to be displayed, it will assume as initial OBJ the index defined in SPT3 and it display every OBJ reading backwards, finishing in SPT2. The address of each value is:

0005F848h - SPT0
0005F84Ah - SPT1
0005F84Ch - SPT2
0005F84Eh - SPT3

I think that the following diagram will explain better this concept.

prog003.gif (5664 bytes)

So, the OBJ lets you define different patterns to display sprites, this patterns will be defined by programmer according to the expected game control of sprites in scene. The demo called "The Croach" uses a basic technique where every frame on the croach animation is ordered in OBJ map and we move the SPT3/SPT2 values after some waiting time making the effect of a croach moving on the screen.

Control Animation

Ok, we know how to display an sprite, or a BGMap, or any element in display, but what about control this animation, to display it right on the VB. Well, the known VB games use different techniques to perform the animation control. Here is some control techniques:

  • XPSTTS: This VIP Reg value tell us when the VB is ready to display on screen, performing a XOR operation on its value according to each display defined in the most significant bits. The value changes from C000h to 0h, and obviously the last 2 bits on means the right and left leds, ready to display. The Croach demo use this technique calling a routine that waits some canges on this value before return. Look this routine:

.mov32 0x0005F800, $1    ;Get VIP Ptr
ld.w 0x40[$1], $5        ;Store XPSTTS value
ld.w 0x40[$1], $6        ;Loop until different
cmp $6, $5
be -6

  • Ints: Many games uses the interrupts calls to perform animation sequences or manage values in OBJs. The common interrupts to handle animation are Timer Int and Video Int. In fact, the Video Int is the most called routine in VB games. To call every interrupt you must set the Int flags properly. Personaly, I've worked with Timer Int (used in Cursor Demo), but not with Video Int, but in theory each interrupt work as follows:
Timer Int Video Int
  • Set the THB and TLB values to define timer wait. The address of each register are 0200001Ch and 02000018h.
  • Set Timer register (TCR) to 0x09 to enable interrupt and enable the timer. The address of TCR is 02000020h.
  • Wait the zero flag (the second bit in TCR) or make properly code to call some routine in the interrupt vector, according to the purpose of the timer.
  • Disable the int enable flag if you don't want it.
  • Enable the interrupt setting in VIP INTENB reg the 0x4008 value.
  • Define a routine call in the interrupt vector.
  • Disable the interrupt if you don't want it.

I hope this document will be helpful to understand the animation stuff on Virtual Boy and you get ready to code a demo on this console. Again, thanks to David Tucker and it's page for provides me the needed documentation for this reference.

Any comment? Write us: virtuale98@yahoo.com

The Virtual Boy and Nintendo logos are trademarks of Nintendo Co. Ltd.