Skip to content

Commit

Permalink
master: ficheros iniciales fase 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengLong Zou committed Sep 27, 2012
0 parents commit d863472
Show file tree
Hide file tree
Showing 24 changed files with 1,572 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.d
*.o
*.elf
*.nds
*.pnps
*.DS_Store
45 changes: 45 additions & 0 deletions GARLIC_API/GARLIC_API.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*------------------------------------------------------------------------------
"GARLIC_API.h" : cabeceras de funciones del API (Application Program
Interface) del sistema operativo GARLIC (código fuente
disponible en "GARLIC_API.s")
------------------------------------------------------------------------------*/
#ifndef _GARLIC_API_h_
#define _GARLIC_API_h_


/* GARLIC_random: devuelve un número aleatorio de 32 bits */
extern int GARLIC_random();

/* GARLIC_divmod: calcula la división num / den (numerador / denominador),
almacenando el cociente y el resto en las posiciones de memoria indica-
das por *quo y *mod, respectivamente (pasa resultados por referencia);
la función devuelve 0 si la división és correcta, o diferente de 0
si hay algún problema (división por cero).
ATENCIóN: sólo procesa números naturales de 32 bits SIN signo. */
extern int GARLIC_divmod(unsigned int num, unsigned int den,
unsigned int * quo, unsigned int * mod);

/* GARLIC_num2str: convertir el número pasado por valor en el parámetro num
a una representación en códigos ASCII de los dígitos decimales corres-
pondientes, que se escribirán dentro del vector de caracteres numstr,
que se pasa por referencia; el parámetro length indicará la longitud del
vector; esta función coloca un caracter centinela (cero) en la última
posición del vector (numstr[length-1]) y, a partir de la penúltima
posición, empieza a colocar los códigos ASCII correspondientes a las
unidades, decenas, centenas, etc.; en el caso que después de trancribir
todo el número todavía queden posiciones libres en el vector, la función
rellenará dichas posiciones con espacios en blanco, y devolverá un cero;
en el caso que NO hayan suficientes posiciones para transcribir todo el
número, la función abandonará el proceso y devolverá un valor diferente
de cero.
ATENCIóN: sólo procesa números naturales de 32 bits SIN signo. */
extern int GARLIC_num2str(char * numstr, unsigned int length, unsigned int num);

/* GARLIC_print: escribir string en la ventana del proceso actual */
extern void GARLIC_print(char * string);



#endif // _GARLIC_API_h_
1 change: 1 addition & 0 deletions GARLIC_API/GARLIC_API.pnproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project name="GARLIC_API"><File path="GARLIC_API.h"></File><File path="GARLIC_API.s"></File><File path="Makefile"></File></Project>
44 changes: 44 additions & 0 deletions GARLIC_API/GARLIC_API.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@;==============================================================================
@;
@; "GARLIC_API.s": implementación de funciones del API del sistema operativo
@; GARLIC (descripción de funciones en "GARLIC_API.h")
@;
@;==============================================================================

.text
.arm
.align 2

.global GARLIC_random
GARLIC_random:
push {r4, lr}
mov r4, #0 @; vector base de funciones GARLIC
mov lr, pc @; guardar dirección de retorno
ldr pc, [r4] @; llamada indirecta a la función 0x00 de GARLIC
pop {r4, pc}

.global GARLIC_divmod
GARLIC_divmod:
push {r4, lr}
mov r4, #0
mov lr, pc
ldr pc, [r4, #4] @; llamada indirecta a la función 0x01
pop {r4, pc}

.global GARLIC_num2str
GARLIC_num2str:
push {r4, lr}
mov r4, #0
mov lr, pc
ldr pc, [r4, #8] @; llamada indirecta a la función 0x02
pop {r4, pc}

.global GARLIC_print
GARLIC_print:
push {r4, lr}
mov r4, #0
mov lr, pc
ldr pc, [r4, #12] @; llamada indirecta a la función 0x03
pop {r4, pc}

.end
21 changes: 21 additions & 0 deletions GARLIC_API/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#-------------------------------------------------------------------------------
# Makefile for GARLIC API's Object (interface routines)
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# options for Object code generation
#-------------------------------------------------------------------------------
ARCH := -march=armv5te -mlittle-endian

ASFLAGS := -g0 $(ARCH) -mcpu=arm946e-s
# -g0 : disable debug info generation
# $(ARCH) -mcpu=arm946e-s : define architecture and machine

#-------------------------------------------------------------------------------
# make commands
#-------------------------------------------------------------------------------

GARLIC_API.o : GARLIC_API.s
@echo "assembling GARLIC_API.s into GARLIC_API.o"
@arm-eabi-as $(ASFLAGS) GARLIC_API.s -o GARLIC_API.o

1 change: 1 addition & 0 deletions GARLIC_OS/GARLIC_OS.pnproj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project name="GARLIC_OS"><MagicFolder excludeFolders="CVS;.svn" filter="*.c;*.s" name="source" path="source\"><File path="garlic_dtcm.s"></File><File path="garlic_font.s"></File><File path="garlic_graf.c"></File><File path="garlic_itcm_api.s"></File><File path="garlic_itcm_proc.s"></File><File path="garlic_mem.c"></File><File path="garlic_vectors.s"></File><File path="main.c"></File></MagicFolder><MagicFolder excludeFolders="CVS;.svn" filter="*.h" name="include" path="include\"><File path="garlic_font.h"></File><File path="garlic_system.h"></File></MagicFolder><File path="Makefile"></File></Project>
156 changes: 156 additions & 0 deletions GARLIC_OS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------

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

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

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

include $(DEVKITARM)/base_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
# DATA contains .bin files with extra data for the project (e.g. graphic tiles)
# NITRODATA contains the "virtual" file system accessed through filesystem lib
#-------------------------------------------------------------------------------
TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source
INCLUDES := include
DATA := data
NITRODATA := nitrofiles

#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
ARCH := -march=armv5te -mlittle-endian

CFLAGS := -Wall -g -O2 \
$(ARCH) -mtune=arm946e-s -fomit-frame-pointer -ffast-math
# -Wall : enable all warnings
# -g : enable debug info generation
# -O2 : code optimization level 2
# $(ARCH) -mtune=arm946e-s : tune code generation for specific machine
# -fomit-frame-pointer : avoid to use a 'frame-pointer' register in functions that do not need it
# -ffast-math : optimize math operations

CFLAGS += $(INCLUDE) -DARM9

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=ds_arm9.specs $(ARCH) -mno-fpu

#-------------------------------------------------------------------------------
# any extra libraries we wish to link with the project (order is important)
#-------------------------------------------------------------------------------
LIBS := -lfilesystem -lfat -lnds9

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

#---------------------------------------------------------------------------------
# check if the build directory is not created yet
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------

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

export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
AFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin)))

export OFILES := $(BINFILES:.bin=.o) $(CFILES:.c=.o)
export SFILES := $(AFILES:.s=.o)

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

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


#---------------------------------------------------------------------------------
# use CC for linking standard C projects
#---------------------------------------------------------------------------------
export LD := $(CC)

export GAME_TITLE := GARLIC_OS_v1
export GAME_SUBTITLE1 := Practica de Estructura de Sistemas Operativos
export GAME_SUBTITLE2 := Departamento de Ingenieria Informatica y Matematicas (URV)
export GAME_ICON := $(DEVKITPRO)/libnds/icon.bmp

export _ADDFILES := -d $(CURDIR)/$(NITRODATA)


.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

#---------------------------------------------------------------------------------
run : $(TARGET).nds
@echo "runing $(TARGET).nds with DesmuME"
@$(DESMUME)/DeSmuME.exe $(TARGET).nds &

#---------------------------------------------------------------------------------
debug : $(TARGET).nds $(TARGET).elf
@echo "testing $(TARGET).nds/.elf with DeSmuME_dev/Insight (gdb) through TCP port=1000"
@$(DESMUME)/DeSmuME_dev.exe --arm9gdb=1000 $(TARGET).nds &
@$(DEVKITPRO)/insight/bin/arm-eabi-insight $(TARGET).elf &

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

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

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).nds : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES) $(SFILES)

#---------------------------------------------------------------------------------
%.nds: %.elf
@ndstool -c $@ -9 $< -b $(GAME_ICON) "$(GAME_TITLE);$(GAME_SUBTITLE1);$(GAME_SUBTITLE2)" $(_ADDFILES)
@echo built ... $(notdir $@)

#---------------------------------------------------------------------------------
%.elf:
@echo linking $(notdir $@)
$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) $(SFILES) -o $@

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

-include $(DEPSDIR)/*.d


#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
Binary file added GARLIC_OS/data/garlic_font.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions GARLIC_OS/data/garlic_font.grit
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#-------------------------------------------------------
# graphics in tile format
#-------------------------------------------------------
-gt

#-------------------------------------------------------
# no tile reduction
#-------------------------------------------------------
-mR!

#-------------------------------------------------------
# no map output
#-------------------------------------------------------
-m!

#-------------------------------------------------------
# graphics bit depth is 8 (256 colors)
#-------------------------------------------------------
-gB8

28 changes: 28 additions & 0 deletions GARLIC_OS/include/garlic_font.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

//{{BLOCK(garlic_font)

//======================================================================
//
// garlic_font, 1024x8@8,
// + palette 256 entries, not compressed
// + 128 tiles not compressed
// Total size: 512 + 8192 = 8704
//
// Time-stamp: 2012-08-27, 12:04:15
// Exported by Cearn's GBA Image Transmogrifier, v0.8.8
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================

#ifndef GRIT_GARLIC_FONT_H
#define GRIT_GARLIC_FONT_H

#define garlic_fontTilesLen 8192
extern const unsigned int garlic_fontTiles[2048];

#define garlic_fontPalLen 512
extern const unsigned short garlic_fontPal[256];

#endif // GRIT_GARLIC_FONT_H

//}}BLOCK(garlic_font)
Loading

0 comments on commit d863472

Please sign in to comment.