test2
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/make -f
|
||||
# INCLUDE CONFIGURATION
|
||||
include $(CURDIR)/Makefile.config
|
||||
|
||||
# DEDUCED VARS
|
||||
ALLOBJ = $(patsubst %,$(OBJDIR)/%.o,$(SRC) $(IMG))
|
||||
ALLINC = $(INC:%=$(INCDIR)/%.h)
|
||||
|
||||
# RULES
|
||||
## Make it all (default rule)
|
||||
all: $(NAME).g1a
|
||||
|
||||
## Compile sprites
|
||||
$(OBJDIR)/%.o: $(IMGDIR)/%.bmp
|
||||
fxconv $< -o $@ -n $(<:$(IMGDIR)/%.bmp=img_%)
|
||||
|
||||
## Make the object directory
|
||||
$(OBJDIR):
|
||||
mkdir -p $(OBJDIR)
|
||||
|
||||
## Make an object file out of an ASM source file
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.s
|
||||
$(AS) -c -o $@ $<
|
||||
|
||||
## Make an object file out of a C source file
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(ALLINC)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
## Make the ELF file
|
||||
$(NAME).elf: $(OBJDIR) $(ALLOBJ)
|
||||
$(LD) -o $@ $(ALLOBJ) $(LFLAGS)
|
||||
|
||||
## Make the BIN file
|
||||
$(NAME).bin: $(NAME).elf
|
||||
$(OBJCPY) -R .comment -R .bss -R '$$iop' -O binary $< $@
|
||||
|
||||
## Make the G1A file
|
||||
$(NAME).g1a: $(NAME).bin
|
||||
$(WRAPR) $< -o $(NAME).g1a
|
||||
@stat -c "Build finished -- output size is %s bytes." $(NAME).g1a
|
||||
|
||||
## Clean up your mess
|
||||
clean:
|
||||
$(RM) $(ALLOBJ)
|
||||
$(RM) $(NAME).elf
|
||||
$(RM) $(NAME).bin
|
||||
|
||||
## Clean up everything
|
||||
mrproper: clean
|
||||
$(RM) $(NAME).g1a
|
||||
fclean: mrproper
|
||||
|
||||
## Remake
|
||||
re: fclean all
|
||||
|
||||
## Send to calc
|
||||
send:
|
||||
@if [ ! -f $(NAME).g1a ]; then \
|
||||
echo "Please make before sending."; \
|
||||
else $(SENDR) send $(NAME).g1a \
|
||||
fi
|
||||
## Phuneral phuture ?
|
||||
.PHONY: all clean fclean mrproper re send
|
||||
# END OF FILE
|
|
@ -0,0 +1,46 @@
|
|||
#!/usr/bin/make -f
|
||||
# PROJECT INFORMATION
|
||||
NAME = voiture
|
||||
ICON = ./icon.bmp
|
||||
LIB = gcc
|
||||
|
||||
|
||||
|
||||
## DIRECTORIES
|
||||
SRCDIR = ./src
|
||||
INCDIR = ./include
|
||||
OBJDIR = ./obj
|
||||
LIBDIR = ./lib
|
||||
SCPTDIR = ./scripts
|
||||
IMGDIR = ./img
|
||||
|
||||
# TOOLCHAIN
|
||||
## Directory maker
|
||||
MD = mkdir -p
|
||||
## File remover
|
||||
RM = rm -f
|
||||
## Assembler
|
||||
AS = sh3eb-elf-as
|
||||
## C compiler
|
||||
CC = sh3eb-elf-gcc
|
||||
CFLAGS = -m3 -mb -Os -nostdlib -Wall -Wextra -Wno-main -pedantic -std=c11 -I $(INCDIR) `fxsdk --cflags`
|
||||
## Linker
|
||||
LD = sh3eb-elf-gcc
|
||||
LFLAGS = `fxsdk --cflags` `fxsdk --libs`
|
||||
## Object copier
|
||||
OBJCPY = sh3eb-elf-objcopy
|
||||
## G1A Wrapper
|
||||
WRAPR = g1a-wrapper
|
||||
## Sender
|
||||
SENDR = p7
|
||||
|
||||
# SOURCES
|
||||
SRC = voiture\
|
||||
|
||||
# INCLUDES
|
||||
INC = voiture\
|
||||
|
||||
# SPRITES
|
||||
IMG = menu obstacle formel1\
|
||||
|
||||
# END OF FILE
|
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 553 B |
After Width: | Height: | Size: 338 B |
After Width: | Height: | Size: 354 B |
After Width: | Height: | Size: 359 B |
After Width: | Height: | Size: 460 B |
After Width: | Height: | Size: 205 B |
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 452 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 206 B |
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 210 B |
After Width: | Height: | Size: 202 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 654 B |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 2.7 KiB |
|
@ -0,0 +1,22 @@
|
|||
#ifndef _VOITURE
|
||||
#define _VOITURE
|
||||
|
||||
unsigned int key;
|
||||
char obstacles[100]; // permet d'avoir de l'aléatoire pondéré pour les obstacles/bonus
|
||||
|
||||
|
||||
|
||||
typedef struct Obstacles
|
||||
{
|
||||
char num_obst;
|
||||
short coordx;
|
||||
}Obstacles;
|
||||
|
||||
int Menu(void);
|
||||
int Jeu(void);
|
||||
void draw_lines(int decalx);
|
||||
void init_obstacle(void);
|
||||
void mort(int score, int type);
|
||||
void garage(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,284 @@
|
|||
#include "voiture.h"
|
||||
|
||||
#include "display.h"
|
||||
#include "keyboard.h"
|
||||
#include "stdio.h"
|
||||
#include "clock.h"
|
||||
|
||||
static int SysCallCode[] = {0xD201422B,0x60F20000,0x80010070};
|
||||
static int (*SysCall)(int R4, int R5, int R6, int R7, int FNo ) = (void*)&SysCallCode;
|
||||
|
||||
int RTC_getTicks()
|
||||
{
|
||||
return (*SysCall)(0, 0, 0, 0, 0x3B);
|
||||
}
|
||||
|
||||
Obstacles obstacle[4];
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
//if(!memory_exists("\\\\fls0\\F1rush.sav")) memory_createfile("\\\\fls0\\F1rush.sav",10); // on creer le fichier
|
||||
|
||||
Menu();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Menu()
|
||||
{
|
||||
short menu=0;
|
||||
char key=0;
|
||||
|
||||
extern Image img_menu;
|
||||
|
||||
while(1)
|
||||
{
|
||||
dclear();
|
||||
|
||||
dimage(0, 0, &img_menu);
|
||||
|
||||
dreverse_area(62+16*menu,23+21*menu,108+16*menu,39+21*menu);
|
||||
|
||||
key=getkey();
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case KEY_UP : case KEY_DOWN : menu=!menu; break;
|
||||
case KEY_EXE :
|
||||
|
||||
switch(menu)
|
||||
{
|
||||
case 0 : Jeu(); break;
|
||||
case 1 : /*garage();*/ break;
|
||||
}
|
||||
|
||||
case KEY_EXIT : return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*void garage(void)
|
||||
{
|
||||
unsigned char prix[5]={20,50,90,150,300};
|
||||
unsigned char choice[2]={0,0};
|
||||
int i;
|
||||
char buffer[50];
|
||||
char choix=0;
|
||||
int j,k;
|
||||
|
||||
while(1)
|
||||
{
|
||||
Bdisp_AllClr_DDVRAM();
|
||||
|
||||
ML_bmp_or(IMG_GARAGE, 0, 0, 128, 64);
|
||||
|
||||
|
||||
for(i=0;i<choice[0];i++)
|
||||
{
|
||||
ML_rectangle(58+9*i,33,62+9*i,37,1,1,2);
|
||||
ML_display_vram();
|
||||
}
|
||||
|
||||
for(i=0;i<choice[1];i++)
|
||||
{
|
||||
ML_rectangle(58+9*i,43,62+9*i,47,1,1,2);
|
||||
ML_display_vram();
|
||||
}
|
||||
|
||||
PrintMini(5,32+10*choix,"->",0);
|
||||
|
||||
sprintf(buffer,"argent %d prix %d" , 500, 500);
|
||||
PrintMini(11,17,buffer,0);
|
||||
|
||||
GetKey(&key);
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case KEY_CTRL_UP : case KEY_CTRL_DOWN : choix=(choix== 1 ? 0 : 1); break;
|
||||
case KEY_CTRL_EXE : choice[choix]++; break;
|
||||
case KEY_CTRL_EXIT : return ;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
int Jeu()
|
||||
{
|
||||
|
||||
extern Image img_formel1;
|
||||
extern Image img_obstacle;
|
||||
|
||||
unsigned char decal=1;
|
||||
short decalx_car=24;
|
||||
int start_time=0;
|
||||
int speed=50;
|
||||
unsigned int i=0,j=0;
|
||||
char appuie=0;
|
||||
int score=0;
|
||||
char vie=1;
|
||||
int max=100;
|
||||
int money=0;
|
||||
short essence=100;
|
||||
|
||||
init_obstacle();
|
||||
|
||||
while(1)
|
||||
{
|
||||
dclear();
|
||||
speed=(score%5==0 ? speed+1: speed);
|
||||
draw_lines(i);
|
||||
|
||||
dimage(decalx_car-19, 11*decal, &img_formel1);
|
||||
|
||||
for(j=0;j<4;j++)
|
||||
{
|
||||
obstacle[j].coordx-=2+speed/25;
|
||||
// ML_bmp_or(*(OBSTACLES+obstacle[j].num_obst), obstacle[j].coordx, 11*(j+1), 10, 10);
|
||||
dimage_part(obstacle[j].coordx, 11*(j+1), &img_obstacle, 10*obstacle[j].num_obst, 10*obstacle[j].num_obst +10, 10, 10);
|
||||
|
||||
if(obstacle[j].coordx<0)
|
||||
{
|
||||
srand(RTC_getTicks());
|
||||
obstacle[j].num_obst=obstacles[rand()%100];
|
||||
obstacle[j].coordx=128+40*j;
|
||||
}
|
||||
if(obstacle[0].num_obst==1 && obstacle[1].num_obst==1 && obstacle[2].num_obst==1 && obstacle[3].num_obst==1) obstacle[0].num_obst=0;
|
||||
}
|
||||
|
||||
if(obstacle[decal-1].coordx<decalx_car && obstacle[decal-1].coordx>decalx_car-20 && obstacle[decal-1].num_obst>0)
|
||||
{
|
||||
switch(obstacle[decal-1].num_obst)
|
||||
{
|
||||
case 1 : if(vie==1)
|
||||
{
|
||||
mort(score, 0); return 1;
|
||||
}
|
||||
else vie--; break;
|
||||
case 2 : speed+=25; break;
|
||||
case 3 : speed-=25; break;
|
||||
case 4 : vie++; break;
|
||||
case 5 : decalx_car=74; start_time=RTC_getTicks(); obstacle[decal-1].num_obst=0;break;
|
||||
case 6 : essence=max; break;
|
||||
case 7 : money++; break;
|
||||
case 8 : money+=2; break;
|
||||
}
|
||||
|
||||
if(decalx_car==74 && (int)(RTC_getTicks()-start_time)>192)
|
||||
{
|
||||
decalx_car=24;
|
||||
}
|
||||
|
||||
obstacle[decal-1].num_obst=0;
|
||||
}
|
||||
if(essence<=0)
|
||||
{
|
||||
mort(score, 1);
|
||||
return 1;
|
||||
}
|
||||
essence=(i%26==0 ? essence-10 : essence); //chaque seconde 10 d'essence partent
|
||||
|
||||
dupdate();
|
||||
|
||||
|
||||
if(getkey_opt(0x00, 1)==KEY_UP && appuie==0) // KEY_CTRL_UP
|
||||
{
|
||||
decal=(decal<=1 ? 1 : decal-1);
|
||||
appuie=1;
|
||||
}
|
||||
else if(getkey_opt(0x00, 1)==KEY_DOWN && appuie==0) //KEY_CTRL_DOWN
|
||||
{
|
||||
decal=(decal>=4 ? 4 : decal+1);
|
||||
appuie=1;
|
||||
}
|
||||
else if (getkey_opt(0x00, 1)==KEY_NONE) // permet de ne pas rester appuiyer sur la touche (simule le Getkey())
|
||||
{
|
||||
appuie=0;
|
||||
}
|
||||
|
||||
if(getkey_opt(0x00, 1)==KEY_EXIT) //KEY_CTRL_EXIT
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
/*sprintf(buffer,"metre : %d vie : %d", score, vie);
|
||||
PrintMini(1,1,buffer,0);*/
|
||||
|
||||
dprint(1, 1, "metre : %d vie : %d", score, vie);
|
||||
|
||||
/* sprintf(buffer,"essence %d/%d Argent %d ", essence, max, money);
|
||||
PrintMini(1,56,buffer,0);*/
|
||||
|
||||
dprint(1,56,"essence %d/%d Argent %d ", essence, max, money);
|
||||
|
||||
dupdate();
|
||||
|
||||
sleep_us(75000);
|
||||
|
||||
i+=3;
|
||||
score=(i%4==0 ? score+2: score);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void mort(int score , int type)
|
||||
{
|
||||
int key=0;
|
||||
|
||||
dclear();
|
||||
|
||||
while(key == KEY_NONE)
|
||||
{
|
||||
|
||||
dtext(10,10,"Vous etes mort");
|
||||
|
||||
|
||||
key = getkey();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void init_obstacle()
|
||||
{
|
||||
int i=0;
|
||||
|
||||
while(i<100)
|
||||
{
|
||||
if(i<30) obstacles[i]=0; // vide
|
||||
else if (i>=30 && i<70) obstacles[i]=1;
|
||||
else if (i>=70 && i<75) obstacles[i]=2;
|
||||
else if (i>=75 && i<80) obstacles[i]=3;
|
||||
else if (i>=80 && i<83) obstacles[i]=4;
|
||||
else if (i>=83 && i<86) obstacles[i]=5;
|
||||
else if (i>=86 && i<95) obstacles[i]=6;
|
||||
else if (i>=95 && i<98) obstacles[i]=7;
|
||||
else if (i>=98 /*&& i<100*/) obstacles[i]=8;
|
||||
i++;
|
||||
}
|
||||
|
||||
srand(RTC_getTicks());
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
{
|
||||
obstacle[i].num_obst=obstacles[rand()%100];
|
||||
obstacle[i].coordx=128+rand() % (128 - 30) + 30;
|
||||
}
|
||||
}
|
||||
|
||||
void draw_lines(int decalx)
|
||||
{
|
||||
int i,j;
|
||||
for(i=1;i<4;i++)
|
||||
{
|
||||
for(j=0;j<128;j+=4)
|
||||
{
|
||||
dline(2*j-(decalx%4), i*11+10, 2*j+3-(decalx%4), i*11+10, Color_Black);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
dline(10, 1, 128, 1, Color_Black);
|
||||
dline(1, 54, 128, 54, Color_Black);
|
||||
|
||||
dupdate();
|
||||
}
|