mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 02:27:56 +02:00
DynArrays works
because of InitHeap3, malloc3 and free3 functions from the psy-q-sdk
This commit is contained in:
parent
ec2f18f8be
commit
2f5cbbacb7
@ -205,4 +205,5 @@ A_MOVN_S,
|
||||
A_MOVZ_S,
|
||||
A_MOVN_D,
|
||||
A_MOVZ_D,
|
||||
A_LWC2,
|
||||
A_END_DEF
|
||||
|
@ -205,4 +205,5 @@
|
||||
'movz.s',
|
||||
'movn.d',
|
||||
'movz.d',
|
||||
'lwc2',
|
||||
'end_def'
|
||||
|
@ -35,7 +35,7 @@ unit i_ps1;
|
||||
system : system_mipsel_ps1;
|
||||
name : 'PlayStation 1 for MIPSEL';
|
||||
shortname : 'ps1';
|
||||
flags : [tf_no_pic_supported, tf_smartlink_sections, tf_files_case_sensitive];
|
||||
flags : [tf_no_pic_supported, tf_smartlink_sections, tf_files_case_sensitive, tf_requires_proper_alignment];
|
||||
cpu : cpu_mipsel;
|
||||
unit_env : '';
|
||||
extradefines : '';
|
||||
@ -76,15 +76,15 @@ unit i_ps1;
|
||||
(
|
||||
procalign : 8;
|
||||
loopalign : 8;
|
||||
jumpalign : 0;
|
||||
jumpalignskipmax : 0;
|
||||
jumpalign : 8;
|
||||
jumpalignskipmax : 8;
|
||||
coalescealign : 0;
|
||||
coalescealignskipmax: 0;
|
||||
coalescealignskipmax: 8;
|
||||
constalignmin : 0;
|
||||
constalignmax : 8;
|
||||
varalignmin : 0;
|
||||
varalignmax : 8;
|
||||
localalignmin : 8;
|
||||
localalignmin : 0;
|
||||
localalignmax : 8;
|
||||
recordalignmin : 0;
|
||||
recordalignmax : 8;
|
||||
|
223
cube.pas
Normal file
223
cube.pas
Normal file
@ -0,0 +1,223 @@
|
||||
{$MODE OBJFPC}
|
||||
uses libstd, libcd, libcomb, libds, libetc, libgpu, libgte;
|
||||
|
||||
|
||||
procedure GsInitGraph(x, y, intmode, dith, varmmode: word); stdcall; external;
|
||||
|
||||
const
|
||||
MODE_NTSC = 0;
|
||||
MODE_PAL = 1;
|
||||
|
||||
|
||||
|
||||
const
|
||||
OTSIZE = 4096;
|
||||
|
||||
vertices : array [0..7] of SVECTOR = (
|
||||
(vx: -128; vy: -128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: -128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: -128; vz: 128; pad: 0 ),
|
||||
(vx: -128; vy: -128; vz: 128; pad: 0 ),
|
||||
(vx: -128; vy: 128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: 128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: 128; vz: 128; pad: 0 ),
|
||||
(vx: -128; vy: 128; vz: 128; pad: 0 ));
|
||||
|
||||
faces : array [0..35] of smallint = (
|
||||
0, 3, 2, // top
|
||||
0, 2, 1, // top
|
||||
4, 0, 1, // front
|
||||
4, 1, 5, // front
|
||||
7, 4, 5, // bottom
|
||||
7, 5, 6, // bottom
|
||||
5, 1, 2, // right
|
||||
5, 2, 6, // right
|
||||
2, 3, 7, // back
|
||||
2, 7, 6, // back
|
||||
0, 4, 7, // left
|
||||
0, 7, 3 // left
|
||||
);
|
||||
|
||||
type
|
||||
|
||||
DoubleBuff = packed record
|
||||
draw : DRAWENV;
|
||||
disp : DISPENV;
|
||||
end;
|
||||
|
||||
var
|
||||
screen : array [0..1] of DoubleBuff; // Struct to hold the display & draw buffers
|
||||
currbuff : byte; // Holds the current buffer number (0 or 1)
|
||||
|
||||
ot : array[0..1, 0..OTSIZE] of dword;
|
||||
|
||||
i : longint;
|
||||
ii : longint;
|
||||
otz : longint;
|
||||
counter : dword;
|
||||
|
||||
poly : array [0..11] of POLY_G3;
|
||||
|
||||
|
||||
procedure setRGB0(var c: DRAWENV; r, g, b: byte);
|
||||
begin
|
||||
c.r0:=r;
|
||||
c.g0:=g;
|
||||
c.b0:=b;
|
||||
end;
|
||||
|
||||
|
||||
procedure ScreenInit(width, height: dword);
|
||||
begin
|
||||
|
||||
ResetGraph(0);
|
||||
InitGeom();
|
||||
|
||||
SetGraphDebug(0);
|
||||
|
||||
|
||||
SetVideoMode(MODE_PAL);
|
||||
GsInitGraph(width, height, 0, 0, 0);
|
||||
|
||||
|
||||
SetDefDispEnv(@screen[0].disp, 0, 0, width, height);
|
||||
SetDefDispEnv(@screen[1].disp, 0, height, width, height);
|
||||
|
||||
SetDefDrawEnv(@screen[0].draw, 0, height, width, height);
|
||||
SetDefDrawEnv(@screen[1].draw, 0, 0, width, height);
|
||||
|
||||
screen[0].disp.screen.x:= 0;
|
||||
screen[0].disp.screen.y:= 0;
|
||||
screen[1].disp.screen.x:= 0;
|
||||
screen[1].disp.screen.y:= 0;
|
||||
|
||||
screen[0].disp.screen.h:= 256;
|
||||
screen[0].disp.screen.w:= 0;
|
||||
screen[1].disp.screen.h:= 256;
|
||||
screen[1].disp.screen.w:= 0;
|
||||
|
||||
|
||||
screen[0].draw.isbg:= 1;
|
||||
screen[1].draw.isbg:= 1;
|
||||
|
||||
// Set the background clear color
|
||||
setRGB0(screen[0].draw, 0, 0, 0);
|
||||
setRGB0(screen[1].draw, 0, 0, 0);
|
||||
|
||||
|
||||
// Initialize and setup the GTE geometry offsets
|
||||
SetGeomOffset(width div 2, height div 2);
|
||||
SetGeomScreen(100);
|
||||
|
||||
SetDispMask(1);
|
||||
|
||||
// Set the current initial buffer
|
||||
currbuff:= 0;
|
||||
PutDispEnv(@screen[currbuff].disp);
|
||||
PutDrawEnv(@screen[currbuff].draw);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure DisplayFrame;
|
||||
begin
|
||||
|
||||
// Set the current display & draw buffers
|
||||
PutDispEnv(@screen[currbuff].disp);
|
||||
PutDrawEnv(@screen[currbuff].draw);
|
||||
|
||||
DrawOTag(@ot[currbuff, OTSIZE - 1]);
|
||||
|
||||
FntFlush(-1);
|
||||
|
||||
if currbuff = 0 then currbuff:=1 else currbuff:=0;
|
||||
|
||||
// Sync and wait for vertical blank
|
||||
DrawSync(0);
|
||||
VSync(0);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
rotation : SVECTOR;
|
||||
translation : VECTOR;
|
||||
transform : MATRIX;
|
||||
|
||||
p : pointer;
|
||||
flg : pointer;
|
||||
nclip : longint;
|
||||
|
||||
ch: pchar;
|
||||
d: dword;
|
||||
|
||||
|
||||
begin
|
||||
|
||||
|
||||
ScreenInit(320, 256);
|
||||
|
||||
|
||||
FntLoad(960, 256);
|
||||
SetDumpFnt(FntOpen(0, 100, 200, 200, 0, 512));
|
||||
|
||||
rotation.vx:= 0;
|
||||
rotation.vy:= 0;
|
||||
rotation.vz:= 0;
|
||||
|
||||
translation.vx:= 0;
|
||||
translation.vy:= 0;
|
||||
translation.vz:= 500;
|
||||
|
||||
counter:= 1;
|
||||
|
||||
// srand(1234);
|
||||
//randomize;
|
||||
|
||||
|
||||
repeat
|
||||
|
||||
ClearOTagR(@ot[currbuff], OTSIZE);
|
||||
|
||||
|
||||
|
||||
rotation.vx += 6;
|
||||
rotation.vy += 8;
|
||||
rotation.vz += 12;
|
||||
|
||||
RotMatrix(@rotation, @transform);
|
||||
TransMatrix(@transform, @translation);
|
||||
|
||||
SetRotMatrix(@transform);
|
||||
SetTransMatrix(@transform);
|
||||
|
||||
for i:= 0 to 11 do begin
|
||||
setPolyG3(@poly[i]);
|
||||
|
||||
poly[i].r0:= 255; poly[i].g0:=0; poly[i].b0:= 0;
|
||||
poly[i].r1:= 0; poly[i].g1:=255; poly[i].b1:= 0;
|
||||
poly[i].r2:= 0; poly[i].g2:=0; poly[i].b2:= 255;
|
||||
{
|
||||
otz:= 0;
|
||||
otz:= otz + RotTransPers(@vertices[faces[i * 3 + 0]], @poly[i].x0, @p, @flg);
|
||||
otz:= otz + RotTransPers(@vertices[faces[i * 3 + 1]], @poly[i].x1, @p, @flg);
|
||||
otz:= otz + RotTransPers(@vertices[faces[i * 3 + 2]], @poly[i].x2, @p, @flg);
|
||||
otz:= otz div 3;
|
||||
}
|
||||
nclip:= RotAverageNclip3(@vertices[faces[i * 3 + 0]], @vertices[faces[i * 3 + 1]], @vertices[faces[i * 3 + 2]], @poly[i].x0, @poly[i].x1, @poly[i].x2, @p, @otz, @flg);
|
||||
if nclip <= 0 then continue;
|
||||
|
||||
if (otz > 0) and (otz < OTSIZE) then addPrim(@ot[currbuff, otz], @poly[i]);
|
||||
end;
|
||||
|
||||
|
||||
counter:= counter + 1;
|
||||
|
||||
FntPrint('Hello from FPC %d', counter);
|
||||
|
||||
|
||||
DisplayFrame;
|
||||
|
||||
until false;
|
||||
|
||||
end.
|
2
f2
2
f2
@ -7,5 +7,5 @@ rm test.elf
|
||||
tm test.bin
|
||||
rm test.psx-exe
|
||||
rm *.res
|
||||
# -Cn
|
||||
# -Cn -XX
|
||||
./compiler/ppcrossmipsel test.pas -a -XX -Fu./rtl/ps1 -Fu./rtl/objpas -Tps1 -Cfnone -Fu./psy-q-sdk/bindings -Fl./psy-q-sdk/lib -XP/usr/local/mipsel-unknown-elf/bin/mipsel-unknown-elf-
|
@ -25,7 +25,7 @@ begin
|
||||
P.Description := 'Process (execution) related parts of Free Component Libraries (FCL), FPC''s OOP library.';
|
||||
P.Options.Add('-S2h');
|
||||
P.NeedLibC:= false;
|
||||
P.OSes:=AllOSes-[embedded,msdos,win16,go32v2,nativent,macosclassic,palmos,atari,zxspectrum,msxdos,amstradcpc,sinclairql,wasi,human68k];
|
||||
P.OSes:=AllOSes-[embedded,msdos,win16,go32v2,nativent,macosclassic,palmos,atari,zxspectrum,msxdos,amstradcpc,sinclairql,wasi,human68k,ps1];
|
||||
if Defaults.CPU=jvm then
|
||||
P.OSes := P.OSes - [java,android];
|
||||
|
||||
|
@ -166,7 +166,7 @@ Type
|
||||
win64,wince,gba,nds,embedded,symbian,haiku,iphonesim,
|
||||
aix,java,android,nativent,msdos,wii,aros,dragonfly,
|
||||
win16,freertos,zxspectrum,msxdos,ios,amstradcpc,sinclairql,
|
||||
wasi,human68k
|
||||
wasi,human68k,ps1
|
||||
);
|
||||
TOSes = Set of TOS;
|
||||
|
||||
@ -293,7 +293,8 @@ Const
|
||||
{amstradcpc}( false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false),
|
||||
{sinclairql}( false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false),
|
||||
{ wasi } ( false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false),
|
||||
{ human68k }( false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false)
|
||||
{ human68k }( false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false),
|
||||
{ ps1 } ( false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false)
|
||||
);
|
||||
|
||||
// Useful
|
||||
|
2426
rtl/ps1/Makefile
2426
rtl/ps1/Makefile
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,7 @@
|
||||
unit system;
|
||||
interface
|
||||
|
||||
{$define FPC_IS_SYSTEM}
|
||||
{$DEFINE FPCRTL_FILESYSTEM_SINGLE_BYTE_API}
|
||||
{$define FPC_HAS_FEATURE_DYNLIBS}
|
||||
{$define FPC_HAS_FEATURE_INITFINAL}
|
||||
{$define FPC_HAS_FEATURE_ANSISTRINGS}
|
||||
{define USE_NOTHREADMANAGER}
|
||||
{$define FPC_HAS_FEATURE_THREADING}
|
||||
|
||||
{$I systemh.inc}
|
||||
|
||||
@ -18,9 +12,9 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
procedure _InitHeap(p: pdword; l: dword); external name 'InitHeap';
|
||||
procedure _free(p: pointer); external name 'free';
|
||||
function _malloc(l: dword): pointer; external name 'malloc';
|
||||
procedure _InitHeap(p: pdword; l: dword); external name 'InitHeap2';
|
||||
procedure _free(p: pointer); external name 'free2';
|
||||
function _malloc(l: dword): pointer; external name 'malloc2';
|
||||
|
||||
|
||||
const
|
||||
@ -84,5 +78,4 @@ end;
|
||||
begin
|
||||
InOutRes:= 0;
|
||||
_InitHeap(pdword($800F8000), $00100000);
|
||||
InitSystemThreads;
|
||||
end.
|
226
test.pas
226
test.pas
@ -1,223 +1,21 @@
|
||||
{$MODE OBJFPC}
|
||||
uses libstd, libcd, libcomb, libds, libetc, libgpu, libgte;
|
||||
|
||||
|
||||
procedure GsInitGraph(x, y, intmode, dith, varmmode: word); stdcall; external;
|
||||
|
||||
const
|
||||
MODE_NTSC = 0;
|
||||
MODE_PAL = 1;
|
||||
|
||||
|
||||
|
||||
const
|
||||
OTSIZE = 4096;
|
||||
|
||||
vertices : array [0..7] of SVECTOR = (
|
||||
(vx: -128; vy: -128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: -128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: -128; vz: 128; pad: 0 ),
|
||||
(vx: -128; vy: -128; vz: 128; pad: 0 ),
|
||||
(vx: -128; vy: 128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: 128; vz: -128; pad: 0 ),
|
||||
(vx: 128; vy: 128; vz: 128; pad: 0 ),
|
||||
(vx: -128; vy: 128; vz: 128; pad: 0 ));
|
||||
|
||||
faces : array [0..35] of smallint = (
|
||||
0, 3, 2, // top
|
||||
0, 2, 1, // top
|
||||
4, 0, 1, // front
|
||||
4, 1, 5, // front
|
||||
7, 4, 5, // bottom
|
||||
7, 5, 6, // bottom
|
||||
5, 1, 2, // right
|
||||
5, 2, 6, // right
|
||||
2, 3, 7, // back
|
||||
2, 7, 6, // back
|
||||
0, 4, 7, // left
|
||||
0, 7, 3 // left
|
||||
);
|
||||
|
||||
type
|
||||
|
||||
DoubleBuff = packed record
|
||||
draw : DRAWENV;
|
||||
disp : DISPENV;
|
||||
end;
|
||||
|
||||
{$H+}
|
||||
uses libstd;
|
||||
var
|
||||
screen : array [0..1] of DoubleBuff; // Struct to hold the display & draw buffers
|
||||
currbuff : byte; // Holds the current buffer number (0 or 1)
|
||||
|
||||
ot : array[0..1, 0..OTSIZE] of dword;
|
||||
|
||||
i : longint;
|
||||
ii : longint;
|
||||
otz : longint;
|
||||
counter : dword;
|
||||
|
||||
poly : array [0..11] of POLY_G3;
|
||||
|
||||
|
||||
procedure setRGB0(var c: DRAWENV; r, g, b: byte);
|
||||
begin
|
||||
c.r0:=r;
|
||||
c.g0:=g;
|
||||
c.b0:=b;
|
||||
end;
|
||||
|
||||
|
||||
procedure ScreenInit(width, height: dword);
|
||||
begin
|
||||
|
||||
ResetGraph(0);
|
||||
InitGeom();
|
||||
|
||||
SetGraphDebug(0);
|
||||
|
||||
|
||||
SetVideoMode(MODE_PAL);
|
||||
GsInitGraph(width, height, 0, 0, 0);
|
||||
|
||||
|
||||
SetDefDispEnv(@screen[0].disp, 0, 0, width, height);
|
||||
SetDefDispEnv(@screen[1].disp, 0, height, width, height);
|
||||
|
||||
SetDefDrawEnv(@screen[0].draw, 0, height, width, height);
|
||||
SetDefDrawEnv(@screen[1].draw, 0, 0, width, height);
|
||||
|
||||
screen[0].disp.screen.x:= 0;
|
||||
screen[0].disp.screen.y:= 0;
|
||||
screen[1].disp.screen.x:= 0;
|
||||
screen[1].disp.screen.y:= 0;
|
||||
|
||||
screen[0].disp.screen.h:= 256;
|
||||
screen[0].disp.screen.w:= 0;
|
||||
screen[1].disp.screen.h:= 256;
|
||||
screen[1].disp.screen.w:= 0;
|
||||
|
||||
|
||||
screen[0].draw.isbg:= 1;
|
||||
screen[1].draw.isbg:= 1;
|
||||
|
||||
// Set the background clear color
|
||||
setRGB0(screen[0].draw, 0, 0, 0);
|
||||
setRGB0(screen[1].draw, 0, 0, 0);
|
||||
|
||||
|
||||
// Initialize and setup the GTE geometry offsets
|
||||
SetGeomOffset(width div 2, height div 2);
|
||||
SetGeomScreen(100);
|
||||
|
||||
SetDispMask(1);
|
||||
|
||||
// Set the current initial buffer
|
||||
currbuff:= 0;
|
||||
PutDispEnv(@screen[currbuff].disp);
|
||||
PutDrawEnv(@screen[currbuff].draw);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure DisplayFrame;
|
||||
begin
|
||||
|
||||
// Set the current display & draw buffers
|
||||
PutDispEnv(@screen[currbuff].disp);
|
||||
PutDrawEnv(@screen[currbuff].draw);
|
||||
|
||||
DrawOTag(@ot[currbuff, OTSIZE - 1]);
|
||||
|
||||
FntFlush(-1);
|
||||
|
||||
if currbuff = 0 then currbuff:=1 else currbuff:=0;
|
||||
|
||||
// Sync and wait for vertical blank
|
||||
DrawSync(0);
|
||||
VSync(0);
|
||||
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
rotation : SVECTOR;
|
||||
translation : VECTOR;
|
||||
transform : MATRIX;
|
||||
|
||||
p : pointer;
|
||||
flg : pointer;
|
||||
nclip : longint;
|
||||
|
||||
ch: pchar;
|
||||
d: dword;
|
||||
|
||||
|
||||
s : string;
|
||||
begin
|
||||
|
||||
printf('GO'#10);;
|
||||
|
||||
ScreenInit(320, 256);
|
||||
s:= 'Hallo';
|
||||
s:= s + '!' ;
|
||||
|
||||
if s <> 'Hallo' then begin
|
||||
printf('cool'#10);
|
||||
end;
|
||||
|
||||
FntLoad(960, 256);
|
||||
SetDumpFnt(FntOpen(0, 100, 200, 200, 0, 512));
|
||||
s:= s + #10 + #0;
|
||||
|
||||
rotation.vx:= 0;
|
||||
rotation.vy:= 0;
|
||||
rotation.vz:= 0;
|
||||
printf(pchar(@s[1]));
|
||||
|
||||
translation.vx:= 0;
|
||||
translation.vy:= 0;
|
||||
translation.vz:= 500;
|
||||
|
||||
counter:= 1;
|
||||
|
||||
// srand(1234);
|
||||
//randomize;
|
||||
|
||||
|
||||
repeat
|
||||
|
||||
ClearOTagR(@ot[currbuff], OTSIZE);
|
||||
|
||||
|
||||
|
||||
rotation.vx += 6;
|
||||
rotation.vy += 8;
|
||||
rotation.vz += 12;
|
||||
|
||||
RotMatrix(@rotation, @transform);
|
||||
TransMatrix(@transform, @translation);
|
||||
|
||||
SetRotMatrix(@transform);
|
||||
SetTransMatrix(@transform);
|
||||
|
||||
for i:= 0 to 11 do begin
|
||||
setPolyG3(@poly[i]);
|
||||
|
||||
poly[i].r0:= 255; poly[i].g0:=0; poly[i].b0:= 0;
|
||||
poly[i].r1:= 0; poly[i].g1:=255; poly[i].b1:= 0;
|
||||
poly[i].r2:= 0; poly[i].g2:=0; poly[i].b2:= 255;
|
||||
{
|
||||
otz:= 0;
|
||||
otz:= otz + RotTransPers(@vertices[faces[i * 3 + 0]], @poly[i].x0, @p, @flg);
|
||||
otz:= otz + RotTransPers(@vertices[faces[i * 3 + 1]], @poly[i].x1, @p, @flg);
|
||||
otz:= otz + RotTransPers(@vertices[faces[i * 3 + 2]], @poly[i].x2, @p, @flg);
|
||||
otz:= otz div 3;
|
||||
}
|
||||
nclip:= RotAverageNclip3(@vertices[faces[i * 3 + 0]], @vertices[faces[i * 3 + 1]], @vertices[faces[i * 3 + 2]], @poly[i].x0, @poly[i].x1, @poly[i].x2, @p, @otz, @flg);
|
||||
if nclip <= 0 then continue;
|
||||
|
||||
if (otz > 0) and (otz < OTSIZE) then addPrim(@ot[currbuff, otz], @poly[i]);
|
||||
end;
|
||||
|
||||
|
||||
counter:= counter + 1;
|
||||
|
||||
FntPrint('Hello from FPC %d', counter);
|
||||
|
||||
|
||||
DisplayFrame;
|
||||
|
||||
until false;
|
||||
|
||||
end.
|
||||
end.
|
Loading…
Reference in New Issue
Block a user