Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Timers work now.

  • Loading branch information
Darren Alton committed Aug 18, 2008
1 parent 9f8db75 commit 0d9edf04a86c15c0b2a3a04c8431b49aa2ceaca0
@@ -67,7 +67,7 @@ src/thread/nds/SDL_syscond.c \
src/thread/nds/SDL_sysmutex.c \
src/thread/nds/SDL_syssem.c \
src/thread/nds/SDL_systhread.c \
src/timer/dummy/SDL_systimer.c \
src/timer/nds/SDL_systimer.c \
src/timer/SDL_timer.c \
src/video/nds/SDL_ndsevents.c \
src/video/nds/SDL_ndsrender.c \
@@ -110,7 +110,7 @@ typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
#define SDL_THREADS_DISABLED 1

/* Enable various timer systems */
#define SDL_TIMERS_DISABLED 1
#define SDL_TIMER_NDS 1

/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_NDS 1
@@ -28,7 +28,10 @@

#include "SDL_timer.h"
#include "../SDL_timer_c.h"
#include "../SDL_systimer.h"

/* Data to handle a single periodic alarm */
static int timer_alive = 0;
static Uint32 timer_ticks;

void
@@ -57,10 +60,6 @@ SDL_Delay(Uint32 ms)
}
}

/* Data to handle a single periodic alarm */
static int timer_alive = 0;
static int timer_ticks = 0;

static int
RunTimer(void *unused)
{
@@ -72,8 +71,8 @@ RunTimer(void *unused)
return (0);
}

void NDS_TimerInterrupt() {
printf("timer irq\n");
void NDS_TimerInterrupt(void) {
timer_ticks++;
}

/* This is only called if the event thread is not running */
@@ -82,32 +81,34 @@ SDL_SYS_TimerInit(void)
{
timer_alive = 1;
timer_ticks = 0;
TIMER_CR(0) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
TIMER_DATA(0) = TIMER_FREQ_1024(1000);
irqSet(IRQ_TIMER1, NDS_TimerInterrupt);
TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
TIMER_DATA(3) = TIMER_FREQ_1024(1000);
irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
irqEnable(IRQ_TIMER3);
return 0;
}

void
SDL_SYS_TimerQuit(void)
{
if (timer_alive) {
TIMER_CR(0) = 0;
TIMER_CR(3) = 0;
}
timer_alive = 0;
irqDisable(IRQ_TIMER3);
}

int
SDL_SYS_StartTimer(void)
{
TIMER_CR(0) |= TIMER_ENABLE;
TIMER_CR(3) |= TIMER_ENABLE;
return 0;
}

void
SDL_SYS_StopTimer(void)
{
TIMER_CR(0) &= ~TIMER_ENABLE;
TIMER_CR(3) &= ~TIMER_ENABLE;
return;
}

@@ -656,8 +656,7 @@ NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
SDL_Color * colors, int firstcolor, int ncolors)
{
NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata;
TRACE("+NDS_GetTexturePalette\n");
TRACE("-NDS_GetTexturePalette\n");
TRACE("!NDS_GetTexturePalette\n");
return 0;
}

@@ -32,7 +32,7 @@ int main(void) {
SDL_Surface *screen;
SDL_Joystick *stick;
SDL_Event event;
SDL_Rect rect = {8,8,240,176};
SDL_Rect rect = {0,0,256,192};
int i;

consoleDemoInit(); puts("Hello world! Initializing FAT...");
@@ -68,23 +68,14 @@ int main(void) {
while(SDL_PollEvent(&event))
switch(event.type) {
case SDL_JOYBUTTONDOWN:
switch(event.jbutton.which) {
case 0:
SDL_FillRect(screen, &rect, RGB15(31,0,0)|0x8000);
break;
case 1:
SDL_FillRect(screen, &rect, RGB15(0,31,0)|0x8000);
break;
case 2:
SDL_FillRect(screen, &rect, RGB15(0,0,31)|0x8000);
break;
case 3:
SDL_FillRect(screen, &rect, RGB15(0,0,0)|0x8000);
break;
default: break;
}
printf("joy_%d, at %d\n", event.jbutton.which, SDL_GetTicks());
SDL_Flip(screen);
SDL_FillRect(screen, &rect, (u16)rand()|0x8000);
SDL_Flip(screen);
if(rect.w > 8) {
rect.x += 4; rect.y += 3;
rect.w -= 8; rect.h -= 6;
}
printf("button %d pressed at %d ticks\n",
event.jbutton.which, SDL_GetTicks());
break;
case SDL_QUIT: SDL_Quit(); return 0;
default: break;

0 comments on commit 0d9edf0

Please sign in to comment.