mirror of
https://github.com/luksamuk/engine-psx.git
synced 2025-04-28 13:28:02 +03:00
Add util library
This commit is contained in:
parent
95e725b99c
commit
ba9125edcd
5 changed files with 66 additions and 27 deletions
|
@ -5,15 +5,20 @@
|
|||
(neotreebuf (seq-filter (lambda (buf) (equal (buffer-name buf) " *NeoTree*"))
|
||||
(buffer-list))))
|
||||
(setq-local flycheck-clang-include-path includes)
|
||||
(setq-local flycheck-gcc-include-path includes)
|
||||
(when neotreebuf
|
||||
(with-current-buffer (first neotreebuf)
|
||||
(setq-local neo-hidden-regexp-list
|
||||
(append '("\\pcsx.json$"
|
||||
"\\.frag$"
|
||||
"\\.vert$"
|
||||
"\\.lua$"
|
||||
"\\.mcd$")
|
||||
(default-value 'neo-hidden-regexp-list)))
|
||||
(neotree-refresh))))))))
|
||||
(setq-local flycheck-gcc-include-path includes)
|
||||
;; (when neotreebuf
|
||||
;; (with-current-buffer (first neotreebuf)
|
||||
;; (let ((excluded '("\\pcsx.json$"
|
||||
;; "\\.frag$"
|
||||
;; "\\.vert$"
|
||||
;; "\\.lua$"
|
||||
;; "\\.mcd$")))
|
||||
;; (unless (every (lambda (n) (not (null n)))
|
||||
;; (mapcar (lambda (x) (member x neo-hidden-regexp-list))
|
||||
;; excluded))
|
||||
;; (setq neo-hidden-regexp-list
|
||||
;; (append excluded (default-value 'neo-hidden-regexp-list)))
|
||||
;; (neotree-refresh)))))
|
||||
)))))
|
||||
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ all: ./build/sonicengine.cue
|
|||
dir: ./build
|
||||
|
||||
run: ./build/sonicengine.cue
|
||||
pcsx-redux-appimage -gdb -run -interpreter -iso ./build/sonicengine.cue
|
||||
pcsx-redux-appimage -gdb -run -interpreter -fastboot -stdout -iso ./build/sonicengine.cue
|
||||
|
||||
./build/sonicengine.cue: ./build
|
||||
cmake --build ./build
|
||||
|
|
10
include/util.h
Normal file
10
include/util.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <psxgte.h>
|
||||
|
||||
int RotAverageNclip4(SVECTOR *a, SVECTOR *b, SVECTOR *c, SVECTOR *d,
|
||||
long *xy0, long *xy1, long *xy2, long *xy3,
|
||||
int *otz);
|
||||
|
||||
#endif
|
27
src/main.c
27
src/main.c
|
@ -5,6 +5,7 @@
|
|||
#include <inline_c.h>
|
||||
|
||||
#include "render.h"
|
||||
#include "util.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static int x = 32, y = 32;
|
||||
|
@ -92,22 +93,18 @@ engine_draw()
|
|||
setRGB2(poly, 0, 0, 128);
|
||||
setRGB3(poly, 128, 128, 0);
|
||||
|
||||
gte_ldv0(&vertices[faces[i]]);
|
||||
gte_ldv1(&vertices[faces[i + 1]]);
|
||||
gte_ldv2(&vertices[faces[i + 2]]);
|
||||
gte_rtpt();
|
||||
gte_nclip();
|
||||
gte_stopz(&nclip);
|
||||
if(nclip <= 0) continue;
|
||||
nclip = RotAverageNclip4(
|
||||
&vertices[faces[i]],
|
||||
&vertices[faces[i + 1]],
|
||||
&vertices[faces[i + 2]],
|
||||
&vertices[faces[i + 3]],
|
||||
(long *)&poly->x0,
|
||||
(long *)&poly->x1,
|
||||
(long *)&poly->x2,
|
||||
(long *)&poly->x3,
|
||||
&otz);
|
||||
|
||||
gte_stsxy0(&poly->x0);
|
||||
gte_ldv0(&vertices[faces[i + 3]]);
|
||||
gte_rtps();
|
||||
gte_stsxy3(&poly->x1, &poly->x2, &poly->x3);
|
||||
gte_avsz4();
|
||||
gte_stotz(&otz);
|
||||
|
||||
if((otz > 0) && (otz < OT_LENGTH)) {
|
||||
if((nclip > 0) && (otz > 0) && (otz < OT_LENGTH)) {
|
||||
sort_prim(poly, otz);
|
||||
increment_prim(sizeof(POLY_G4));
|
||||
}
|
||||
|
|
27
src/util.c
Normal file
27
src/util.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "util.h"
|
||||
#include <inline_c.h>
|
||||
|
||||
int
|
||||
RotAverageNclip4(
|
||||
SVECTOR *a, SVECTOR *b, SVECTOR *c, SVECTOR *d,
|
||||
long *xy0, long *xy1, long *xy2, long *xy3,
|
||||
int *otz)
|
||||
{
|
||||
int nclip = 0;
|
||||
|
||||
gte_ldv0(a);
|
||||
gte_ldv1(b);
|
||||
gte_ldv2(c);
|
||||
gte_rtpt();
|
||||
gte_nclip();
|
||||
gte_stopz(&nclip);
|
||||
if(nclip <= 0) goto exit;
|
||||
gte_stsxy0(xy0);
|
||||
gte_ldv0(d);
|
||||
gte_rtps();
|
||||
gte_stsxy3(xy1, xy2, xy3);
|
||||
gte_avsz4();
|
||||
gte_stotz(otz);
|
||||
exit:
|
||||
return nclip;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue