GBA question
i was thinking of puting something to my game code, like a timer that would tell me when 1/30th of a second has passed so that i can lock my animations to 30 fps cause thats the speed i made them at is that a good idea? how would i do it?
The GBA has 4 built-in timers, and they can be set to four different frequencies: once every 1, 64, 256, or 1024 clock ticks (which correspond to about 0.056, 3.8, 15.2 and 61 microseconds). There are 8 registers for the timers. For each timer, there is a control register and a register that actually tells you how much time has elapsed. They are defined as:
To initialize the timers, use the following definitions:
This is basically the stuff from http://www.thepernproject.com .
Edited by - Aprosenf on February 2, 2002 10:18:36 AM
Edited by - Aprosenf on February 2, 2002 10:20:08 AM
Edited by - Aprosenf on February 2, 2002 10:21:28 AM
#define REG_TM0D *(u16*)0x4000100#define REG_TM0CNT *(u16*)0x4000102#define REG_TM1D *(u16*)0x4000104#define REG_TM1CNT *(u16*)0x4000106#define REG_TM2D *(u16*)0x4000108#define REG_TM2CNT *(u16*)0x400010A#define REG_TM3D *(u16*)0x400010C#define REG_TM3CNT *(u16*)0x400010E
To initialize the timers, use the following definitions:
#define TIME_FREQUENCY_SYSTEM 0x0#define TIME_FREQUENCY_64 0x1#define TIME_FREQUENCY_256 0x2#define TIME_FREQUENCY_1024 0x3#define TIME_OVERFLOW 0x4 // This causes the timer to increment when the timer below it overflows#define TIME_ENABLE 0x80#define TIME_IRQ_ENABLE 040 // This causes it to generate an interrupt when it overflowsREG_TMxCNT = TIME_FREQUENCY_y | TIME_ENABLE; // This enables timer x with a frequency of yREG_TMxD = 0; // Reset the timer// Do the following each frame:start_time = REG_TMxD;if(REG_TMxD - start_time > some_number) // Has 1/30 of a second gone by? Animate();
This is basically the stuff from http://www.thepernproject.com .
Edited by - Aprosenf on February 2, 2002 10:18:36 AM
Edited by - Aprosenf on February 2, 2002 10:20:08 AM
Edited by - Aprosenf on February 2, 2002 10:21:28 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement