Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Ongoing video render work; initial work on NDS Timers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Alton committed Aug 8, 2008
1 parent a61dd30 commit ae9b5d1
Show file tree
Hide file tree
Showing 12 changed files with 14,703 additions and 3 deletions.
116 changes: 116 additions & 0 deletions src/timer/nds/SDL_systimer.c
@@ -0,0 +1,116 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"

#ifdef SDL_TIMER_NDS

#include <nds.h>
#include <nds/timers.h>

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

static Uint32 timer_ticks;

void
SDL_StartTicks(void)
{
if(!timer_alive) {
SDL_SYS_TimerInit();
SDL_SYS_StartTimer();
}

timer_ticks = 0;
}

Uint32
SDL_GetTicks(void)
{
return timer_ticks;
}

void
SDL_Delay(Uint32 ms)
{
Uint32 start = SDL_GetTicks();
while(timer_alive) {
if((SDL_GetTicks() - start) >= ms) break;
}
}

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

static int
RunTimer(void *unused)
{
while (timer_alive) {
if (SDL_timer_running) {
}
SDL_Delay(1);
}
return (0);
}

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

/* This is only called if the event thread is not running */
int
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);
return 0;
}

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

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

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


#endif /* SDL_TIMER_NDS */
/* vi: set ts=4 sw=4 expandtab: */
6 changes: 3 additions & 3 deletions src/video/nds/SDL_ndsrender.c
Expand Up @@ -460,7 +460,7 @@ NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
SDL_SetError("Unsupported texture format");
}
printf("!NDS_UnlockTexture\n");
printf("+NDS_UnlockTexture\n-NDS_UnlockTexture\n");
}

static void
Expand Down Expand Up @@ -502,9 +502,9 @@ NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
// SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
int i;
printf("+NDS_RenderCopy\n");
for(i = 0; i <= 0xFFFF; ++i) {
/*for(i = 0; i <= 0xFFFF; ++i) {
txdat->vram[i] = 0x8000|i;
}
}*/
printf("/txdat->hw_index = %d\n", txdat->hw_index);
#if 0
if (txdat->dirty.list) {
Expand Down
132 changes: 132 additions & 0 deletions test/nds-test/Makefile
@@ -0,0 +1,132 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------

ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif

include $(DEVKITARM)/ds_rules

#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
#---------------------------------------------------------------------------------
TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork

# note: arm9tdmi isn't the correct CPU arch, but anything newer and LD
# *insists* it has a FPU or VFP, and it won't take no for an answer!
CFLAGS := -save-temps -g -Wall -O0\
-mcpu=arm9tdmi -mtune=arm9tdmi \
$(ARCH)

CFLAGS += $(INCLUDE) -DARM9 -D__NDS__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -fno-exceptions -fno-rtti

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -mno-fpu -Wl,-Map,$(notdir $*.map)

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lSDL -lfat -lnds9


#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(LIBNDS)

#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

export OUTPUT := $(CURDIR)/$(TARGET)

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))

export DEPSDIR := $(CURDIR)/$(BUILD)

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)

export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 $(TARGET).ds.gba


#---------------------------------------------------------------------------------
else

DEPENDS := $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).ds.gba : $(OUTPUT).nds
$(OUTPUT).nds : $(OUTPUT).arm9
$(OUTPUT).arm9 : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)

#---------------------------------------------------------------------------------
%.pcx.o : %.pcx
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)


-include $(DEPENDS)

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

0 comments on commit ae9b5d1

Please sign in to comment.