mirror of
https://git.planet-casio.com/Fcalva/Copy3DEngine.git
synced 2024-12-28 04:23:44 +01:00
Branche omega
This commit is contained in:
parent
751e2e9a70
commit
ed2afa0864
14 changed files with 16533 additions and 166 deletions
38
Makefile
Normal file
38
Makefile
Normal file
|
@ -0,0 +1,38 @@
|
|||
CC=sh-elf-gcc
|
||||
CFLAGS= -I/home/fr/.local/include -ffreestanding -flto -nostdlib -Og -Wall -Wextra -Xlinker
|
||||
NAME=
|
||||
FILENAME="omega"
|
||||
OBJCOPY = sh-elf-objcopy
|
||||
SRC_DIR=src
|
||||
CONV_DIR=oconv
|
||||
BUILD_DIR=build
|
||||
|
||||
|
||||
SRC := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/*.s)
|
||||
SRC += $(wildcard $(SRC_DIR)/*/*.c $(SRC_DIR)/*/*.s)
|
||||
|
||||
all: mkdir convert compile clean
|
||||
no_clean : mkdir convert compile
|
||||
mkdir:
|
||||
mkdir -p build
|
||||
|
||||
convert:
|
||||
#cd oconv && python3 convert.py ../assets-cg/
|
||||
#cd ..
|
||||
|
||||
compile: $(FILENAME).g3a
|
||||
|
||||
$(FILENAME).g3a : $(BUILD_DIR)/$(FILENAME).bin
|
||||
mkg3a -n "basic:$(NAME)" -i uns:assets-cg/uns-icon.bmp -i sel:assets-cg/sel-icon.bmp $(BUILD_DIR)/$(FILENAME).bin $(FILENAME).g3a
|
||||
|
||||
$(BUILD_DIR)/$(FILENAME).bin : $(BUILD_DIR)/$(FILENAME).elf
|
||||
$(OBJCOPY) -O binary $(BUILD_DIR)/$(FILENAME).elf $(BUILD_DIR)/$(FILENAME).bin
|
||||
$(BUILD_DIR)/$(FILENAME).elf: $(SRC)
|
||||
sh-elf-gcc $(CFLAGS) -T linker.ld -o $(BUILD_DIR)/$(FILENAME).elf $(SRC) /home/fr/.local/lib/omega.a /home/fr/.local/share/giteapc/Lephenixnoir/OpenLibm/libopenlibm.a $(wildcard $(CONV_DIR)/*.S) -lgcc -lm
|
||||
|
||||
clean:
|
||||
#rm -rf build
|
||||
#rm -f oconv/*.S
|
||||
|
||||
|
||||
.PHONY: all clean
|
BIN
assets-cg/font.png
Normal file
BIN
assets-cg/font.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
1
assets-cg/oconv.txt
Normal file
1
assets-cg/oconv.txt
Normal file
|
@ -0,0 +1 @@
|
|||
font.png : image, font
|
BIN
assets-cg/sel-icon.bmp
Normal file
BIN
assets-cg/sel-icon.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
assets-cg/uns-icon.bmp
Normal file
BIN
assets-cg/uns-icon.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
build/omega.bin
Executable file
BIN
build/omega.bin
Executable file
Binary file not shown.
BIN
build/omega.elf
Executable file
BIN
build/omega.elf
Executable file
Binary file not shown.
73
linker.ld
Normal file
73
linker.ld
Normal file
|
@ -0,0 +1,73 @@
|
|||
ENTRY(_start)
|
||||
MEMORY
|
||||
{
|
||||
|
||||
rom (rx): o = 0x00300000, l = 2M
|
||||
/*First 0x1400 bytes are reserved for VBR (starting at 0x08100000)*/
|
||||
ram (rw): o = 0x08101400, l = 491k
|
||||
|
||||
}
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
_srom = SIZEOF(.pretext) + SIZEOF(.text) + SIZEOF(.rodata);
|
||||
|
||||
.pretext : {
|
||||
*(.text.entry)
|
||||
} > rom
|
||||
.text : {
|
||||
_exch_start = . ;
|
||||
*(.omega.exch)
|
||||
_exch_size = ABSOLUTE (. - _exch_start);
|
||||
|
||||
_inth_start = . ;
|
||||
*(.omega.inth)
|
||||
_inth_size = ABSOLUTE (. - _inth_start);
|
||||
|
||||
. = ALIGN(4);
|
||||
_tlbh_start = . ;
|
||||
*(.omega.tlbh)
|
||||
_tlbh_size = ABSOLUTE (. - _tlbh_start);
|
||||
|
||||
*(.text .text.*)
|
||||
|
||||
} > rom
|
||||
|
||||
|
||||
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*)
|
||||
} > rom
|
||||
|
||||
|
||||
. = ORIGIN(ram);
|
||||
|
||||
.data : {
|
||||
_rdata = .;
|
||||
*(.data .data.*)
|
||||
*(.omega.vram)
|
||||
_ldata = LOADADDR(.data);
|
||||
|
||||
|
||||
|
||||
} > ram AT > rom
|
||||
_sdata = SIZEOF(.data);
|
||||
|
||||
.bss (NOLOAD) : {
|
||||
_rbss = . ;
|
||||
|
||||
*(.bss .bss.* COMMON)
|
||||
|
||||
} > ram :NONE
|
||||
_sbss = SIZEOF(.bss);
|
||||
|
||||
|
||||
|
||||
|
||||
/* not important : comments */
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
}
|
||||
|
||||
|
||||
}
|
72
oconv/convert.py
Normal file
72
oconv/convert.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
from PIL import Image
|
||||
|
||||
def rgb_to_rgb565(rgb_tuple):
|
||||
r = rgb_tuple[0]
|
||||
g = rgb_tuple[1]
|
||||
b = rgb_tuple[2]
|
||||
return (int(r/255*31)<<11)|(int(g/255*63)<<5) | int(b/255*31)
|
||||
|
||||
class image:
|
||||
def __init__(self, path):
|
||||
self.image = Image.open(path)
|
||||
def getImage(self):
|
||||
return self.image
|
||||
def setImage(self,path):
|
||||
self.image = Image.open(path)
|
||||
def getpixels(self):
|
||||
width, height = self.image.size
|
||||
pixels = []
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
pixel = self.image.getpixel((x, y))
|
||||
pixels.append(rgb_to_rgb565(pixel))
|
||||
return pixels
|
||||
|
||||
class converter:
|
||||
def __init__(self, file):
|
||||
self.file = file
|
||||
def getFile(self):
|
||||
return self.file
|
||||
def setFile(self, file):
|
||||
self.file = file
|
||||
|
||||
def write_word(self, data):
|
||||
asm = ""
|
||||
asm += ".word " + hex(data)
|
||||
return asm
|
||||
|
||||
def convert_image(self, symbol, section=".rodata"):
|
||||
img = image(self.file)
|
||||
asmc = f".section {section} \n"
|
||||
asmc += f".global _{symbol}\n"
|
||||
asmc += f"_{symbol}:\n"
|
||||
width,height = img.getImage().size
|
||||
asmc += self.write_word(height) + "\n"
|
||||
asmc += self.write_word(width) + "\n"
|
||||
pixels = img.getpixels()
|
||||
for i in pixels:
|
||||
asmc += self.write_word(i) + "\n"
|
||||
f = open(symbol + ".S", "wb")
|
||||
f.write(asmc.encode('utf-8'))
|
||||
f.close()
|
||||
|
||||
|
||||
dir = sys.argv[1]
|
||||
ls = os.listdir(dir)
|
||||
if not "oconv.txt" in ls:
|
||||
print(" OConv ----- oconv.txt cannot be found")
|
||||
exit()
|
||||
print("\n")
|
||||
conf = open(f"{dir}oconv.txt", 'r').read().replace(" ","")
|
||||
files = conf.split("\n")
|
||||
for file in files:
|
||||
filename, metadatas = file.split(":")
|
||||
type, name = metadatas.split(",")
|
||||
print(f" OConv ----- Converting {filename}")
|
||||
conv = converter(dir+filename)
|
||||
if(type == "image"):
|
||||
conv.convert_image(name)
|
||||
print("\n")
|
8197
oconv/font.S
Normal file
8197
oconv/font.S
Normal file
File diff suppressed because it is too large
Load diff
79
src/main.c
79
src/main.c
|
@ -1,13 +1,18 @@
|
|||
#include <omega/display.h>
|
||||
#include <omega/keyboard.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <gint/image.h>
|
||||
#include <libprof.h>
|
||||
//#include <gint/display.h>
|
||||
//#include <gint/keyboard.h>
|
||||
//#include <gint/image.h>
|
||||
//#include <libprof.h>
|
||||
|
||||
#include "fixed.h"
|
||||
|
||||
//#include "keycodes.h"
|
||||
|
||||
#include "moteur.h"
|
||||
#include "map.h"
|
||||
|
||||
|
@ -21,20 +26,20 @@
|
|||
//
|
||||
//
|
||||
|
||||
#ifndef FXCG50
|
||||
/*#ifndef FXCG50
|
||||
#error Ce code est pour FXCG50/G90+E uniquement, enlevez ce message a vos riques et périls
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
//#define debug //pour afficher les infos de debug
|
||||
|
||||
image_t *tex_index[TINDEX_S];
|
||||
//image_t *tex_index[TINDEX_S];
|
||||
|
||||
extern char map_test[map_w][map_h];
|
||||
|
||||
//Vos images ici
|
||||
|
||||
extern image_t briques0;
|
||||
extern image_t buisson0;
|
||||
//extern image_t briques0;
|
||||
//extern image_t buisson0;
|
||||
|
||||
char exit_game = 0;
|
||||
char disp_frame_time = 0;
|
||||
|
@ -51,7 +56,7 @@ fixed_t planeY;
|
|||
int frame_time = 1;
|
||||
|
||||
void keys_get(){
|
||||
pollevent();
|
||||
//pollevent();
|
||||
|
||||
move();
|
||||
|
||||
|
@ -76,44 +81,47 @@ void keys_get(){
|
|||
void main_menu(){
|
||||
//dtext_opt(198, 100, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, NAMEOFGAME, -1);
|
||||
//dtext_opt(198, 120, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "De " AUTHOR, -1);
|
||||
dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1);
|
||||
//dtext_opt(198, 150, 0xde85, C_NONE, DTEXT_CENTER, DTEXT_TOP, "Appuyez sur une touche", -1);
|
||||
|
||||
dupdate();
|
||||
getkey();
|
||||
//dupdate();
|
||||
//getkey();
|
||||
}
|
||||
|
||||
int main(){
|
||||
dclear(C_WHITE);
|
||||
|
||||
keyboard_setup();
|
||||
|
||||
//dclear(C_WHITE);
|
||||
|
||||
//trucs de chargement
|
||||
|
||||
load_map();
|
||||
//load_map();
|
||||
|
||||
image_t *frame_buffer = image_create_vram();
|
||||
//image_t *frame_buffer = image_create_vram();
|
||||
|
||||
extern image_t *tex_index[TINDEX_S];
|
||||
//extern image_t *tex_index[TINDEX_S];
|
||||
|
||||
tex_index[1] = &buisson0;
|
||||
tex_index[2] = &briques0;
|
||||
//tex_index[1] = &buisson0;
|
||||
//tex_index[2] = &briques0;
|
||||
|
||||
//Vos textures générées procéduralement
|
||||
|
||||
tex_index[0] = image_alloc(64, 64, IMAGE_RGB565);
|
||||
tex_index[3] = image_alloc(64, 64, IMAGE_RGB565);
|
||||
//tex_index[0] = image_alloc(64, 64, IMAGE_RGB565);
|
||||
//tex_index[3] = image_alloc(64, 64, IMAGE_RGB565);
|
||||
|
||||
image_fill(tex_index[0], 0x4228);
|
||||
image_fill(tex_index[3], 0x9dbd);
|
||||
//image_fill(tex_index[0], 0x4228);
|
||||
//image_fill(tex_index[3], 0x9dbd);
|
||||
|
||||
prof_init();
|
||||
//prof_init();
|
||||
|
||||
while (!exit_game) {
|
||||
prof_t frame = prof_make();
|
||||
prof_enter(frame);
|
||||
//prof_t frame = prof_make();
|
||||
//prof_enter(frame);
|
||||
|
||||
drect(0, 0, 395, 112, 0x9dbd);
|
||||
drect(0,112, 395, 243, 0xc4c9);
|
||||
|
||||
draw_walls(frame_buffer);
|
||||
draw_walls(/*frame_buffer*/);
|
||||
|
||||
if(first_frame == 1){
|
||||
main_menu();
|
||||
|
@ -121,29 +129,30 @@ int main(){
|
|||
|
||||
keys_get();
|
||||
|
||||
if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time);
|
||||
//if (disp_frame_time == 1) dprint( 1, 10, C_BLACK, "Frame time : %d ms", frame_time);
|
||||
|
||||
#ifdef debug
|
||||
/*#ifdef debug
|
||||
dprint( 1, 20, C_BLACK, "planeX : %d", planeX);
|
||||
dprint( 1, 30, C_BLACK, "planeY : %d", planeY);
|
||||
dprint( 1, 40, C_BLACK, "dirX : %d", dirX);
|
||||
dprint( 1, 50, C_BLACK, "dirY : %d", dirY);
|
||||
dprint( 1, 60, C_BLACK, "posX : %d", posX);
|
||||
dprint( 1, 70, C_BLACK, "posY : %d", posY);
|
||||
#endif
|
||||
#endif*/
|
||||
|
||||
dupdate();
|
||||
prof_leave(frame);
|
||||
frame_time = (int)prof_time(frame)/1000;
|
||||
//prof_leave(frame);
|
||||
//frame_time = (int)prof_time(frame)/1000;
|
||||
first_frame = 0;
|
||||
}
|
||||
|
||||
prof_quit();
|
||||
//prof_quit();
|
||||
|
||||
//Libérez vos textures générées procéduralement
|
||||
|
||||
image_free(tex_index[0]);
|
||||
image_free(tex_index[3]);
|
||||
//image_free(tex_index[0]);
|
||||
//image_free(tex_index[3]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
39
src/moteur.c
39
src/moteur.c
|
@ -2,15 +2,20 @@
|
|||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
//#include <string.h>
|
||||
//#include <time.h>
|
||||
|
||||
#include <gint/display.h>
|
||||
#include <gint/keyboard.h>
|
||||
#include <libprof.h>
|
||||
#include <omega/display.h>
|
||||
#include <omega/keyboard.h>
|
||||
|
||||
//#include <gint/display.h>
|
||||
//#include <gint/keyboard.h>
|
||||
//#include <libprof.h>
|
||||
|
||||
#include "fixed.h"
|
||||
|
||||
//#include "keycodes.h"
|
||||
|
||||
#include "moteur.h"
|
||||
#include "map.h"
|
||||
|
||||
|
@ -86,7 +91,7 @@ void move() {
|
|||
if (dirX < -0xFFFF) dirX = -0xFFFF;
|
||||
if (dirY < -0xFFFF) dirY = -0xFFFF;
|
||||
}
|
||||
|
||||
/*
|
||||
void spawn_gen(){
|
||||
extern fixed_t posX;
|
||||
extern fixed_t posY;
|
||||
|
@ -164,16 +169,16 @@ void spawn_gen(){
|
|||
|
||||
void load_map(){
|
||||
spawn_gen();
|
||||
}
|
||||
}*/
|
||||
|
||||
void draw_walls(image_t *frame_buffer){
|
||||
void draw_walls(){
|
||||
extern fixed_t posX;
|
||||
extern fixed_t posY;
|
||||
extern fixed_t dirX;
|
||||
extern fixed_t dirY;
|
||||
extern fixed_t planeX;
|
||||
extern fixed_t planeY;
|
||||
extern image_t *tex_index[TINDEX_S];
|
||||
//extern image_t *tex_index[TINDEX_S];
|
||||
extern char map_test[map_w][map_h];
|
||||
|
||||
fixed_t cameraX;
|
||||
|
@ -199,7 +204,7 @@ void draw_walls(image_t *frame_buffer){
|
|||
int v_offset = 0; //(int)(sin(f2int(posX + posY)) * 5); //a raffiner un peu
|
||||
fixed_t h_offset = 0; //fix(sin(f2int(posX - posY)) * 0.01);
|
||||
|
||||
struct image_linear_map temp;
|
||||
//struct image_linear_map temp;
|
||||
|
||||
for(x = 0; x < viewport_w; x++) {
|
||||
|
||||
|
@ -253,7 +258,7 @@ void draw_walls(image_t *frame_buffer){
|
|||
sideDistY = fmul( fix(mapY + 1) - posY, deltaDistY);
|
||||
}
|
||||
//perform DDA
|
||||
while(true) {
|
||||
while(1) {
|
||||
//Check if the ray is out of range/bounds
|
||||
if (sideDistX >= max_dist || sideDistY >= max_dist || mapX < 0 || mapY < 0 || mapX >= map_w || mapY >= map_h) {
|
||||
break;
|
||||
|
@ -315,11 +320,15 @@ void draw_walls(image_t *frame_buffer){
|
|||
texSampleY = 0;
|
||||
}
|
||||
|
||||
image_t texStripe;
|
||||
int linePos = viewport_h * 0.5 - lineHeight * 0.5;
|
||||
|
||||
texStripe = *image_sub(tex_index[map_test[mapX][mapY]], texX, texSampleY, 1, texSample);
|
||||
dline(x, linePos, x, linePos+lineHeight, 0xFAFA);
|
||||
|
||||
image_scale(&texStripe, 0xFFFF, texSize, &temp);
|
||||
image_linear(&texStripe, image_at(frame_buffer, x, (int)(viewport_h * 0.5 - lineHeight * 0.5) + v_offset), &temp);
|
||||
//image_t texStripe;
|
||||
|
||||
//texStripe = *image_sub(tex_index[map_test[mapX][mapY]], texX, texSampleY, 1, texSample);
|
||||
|
||||
//image_scale(&texStripe, 0xFFFF, texSize, &temp);
|
||||
//image_linear(&texStripe, image_at(frame_buffer, x, (int)(viewport_h * 0.5 - lineHeight * 0.5) + v_offset), &temp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#ifndef moteur_h
|
||||
#define moteur_h
|
||||
|
||||
#include <gint/image.h>
|
||||
//#include <gint/image.h>
|
||||
|
||||
//param. graphiques
|
||||
#define screen_w 396
|
||||
|
@ -16,7 +16,7 @@
|
|||
|
||||
void load_map();
|
||||
void end_screen();
|
||||
void draw_walls(image_t *frame_buffer);
|
||||
void draw_walls();
|
||||
void move();
|
||||
|
||||
#endif /* moteur */
|
||||
|
|
Loading…
Reference in a new issue