Private PlayStation programming by C/C++
Note: This document is translated by Japanese to English translation sofware. I don't know this is right or not.
NET YAROZE is What fixed results, such as it being very attractive and constructing with a publishing company, and holding a contest or exhibiting a work by pre pre (experience version CD), left at the point that amateur can develop the soft hat of the game machine of the newest , (Thing cheap as development environment) For taking out lightheartedly, a student etc. is high expense. By closing nature that a soft hat can be exhibited only among members by predetermined web/news server, information shortage, etc., as whole, it is cold, and it ended, without assembling the member of 20,000 of a schedule.
However, without depending on such official development environment, it is what is large, and the world is analyzed uniquely, and technical information on PlayStation is exhibited or the man who is making the soft hat is also in it. Some soft hats and information are accumulated on NAPALM .
Programming of PlayStation in information/development environment which can come to hand lawfully is explained here. Finally the library for PS is built and it aims at free development environment by C/C++.
Pro Action Replay for PlayStation
Pro Action Replay for PlayStation (PS-PAR) is the tool for game reconstruction of
English DATEL company
.
It operates with putting to the extended terminal of PlayStation, and a basis basis is a thing for applying and converting a patch into a game and carrying out cheat such as getting items, not to decrease hit points.
Pro Comms Link
Pro Comms Link (PC-LINK) is ISA board for personal computers which makes it possible to communicate by similarly connecting PS-PAR and the personal computer (PC-AT compatible machine) of DATLEL company.
It seems that the same thing for PC-98 also exists.
caetla
caetla
replaces built-in software of PS-PAR, adds functions, such as transmitting and performing the program which the user created, by PC-LINK, and transforms PS-PAR into development environment.
Mr. k-comm. is created and it is opened to the public by
Deaf Dumb & Blind
.
Refer here to for a function or the detailed usage.
For information written in English, refer
NAPALM "CAETLA" section.
First, PS-PAR and PC-LINK are purchased from the import selling contractor who is mail-ordering on the advertisement of the specialty store in Akihabara, or a game lab, or Web. The price is about 1-20,000 yen in great numbers. Next, flash ROM of PS-PAR is replaced by caetla, and environment where the program on a personal computer can be transmitted to PlayStation, and can be performed is prepared.
GNU C/C++ Compiler
GNU C/C++Compiler (gcc) is a free C/C++ compiler corresponding to much platform.
It corresponds to MIPS R3000 which is CPU of PlayStation.
Since source wide distribution is carried out, if the machine (host) to develop, and an execution machine (target) are specified, it can build as a cross compiler.
GNU binutils
GNU binutilses are packages, such as assembler (as) linker (ld) librarian (ar) which corresponded to much platform similarly.
If it is the development by the assembler, it is only here.
Although a.out, coff, elf, etc. are partly in binary object form generally, "ecoff" is used by the NET YAROZE.
Moreover, PlayStation original form called PSX-EXE commonly is used in the final file of CD-ROM.
As for caetla, both correspond.
There is a tool called eco2exe of hitmen in conversion of ecoff to PSX-EXE.
Although GCC and binutils can come to hand and can build the source personally from ftp site of every place , the compiled binary is opened to Win32/x68k by private CO HOMEPAGE (Japanese) or PSX GNU Compiler And Tools (English).
Although the document appended soft is English, since these are the soft hats on Unix from the first and various documents of Unix relation are translated into Japanese on the page of OS of Unix systems, such as Linux , FreeBSD , and NetBSD, There is also a document about these. It seems that moreover, there are also some Japanese books.
Although direction which knows only visual development environment of the latest Windows is probably a stake, it does not need to memorize that it is especially newer to have got used to GCC by x68k or MS-DOS (DJGPP) at the beginning.
Often using are the following options although many options are in GCC.
Probably, it is better to receive, since Makefile is appended to the convenient thing and the exhibited source, in many cases, although it is not indispensable. Although NMAKE of Microsoft, WMAKE of watcom, etc. also have a thing attached to an existing compiler, since format is delicately different, it is safe that GNU Make comes to hand.
Since MAKE does not carry out processing system dependence, it can use the compiled binary for djgpp or for mingw32 , etc. then.
It is an library that it is insufficient for only one. Although a thing called corresponding libc is a free-lancer and GCC is exhibited about general C standard function, there is no library depending on PlayStation called input and output of a pad and drawing of polygon. In the official development environment, although the library which controls hardware of PlayStation is attached, generally, such a thing is not exhibited. It needs to self-construction this portion.
These can be used, since analysis is made all over the world and many information is exhibited now, although for that it needs to know how hardware of PlayStation will have become uniquely.
The reference and execution environment of a NET YAROZE library which spread information which can come to hand by the NET YAROZE when it becomes good general opening a part to the public in connection with a NET YAROZE, and a stop of exclusive server although opened to the public before only in the member by exclusive server are exhibited by WickedBeAT . Moreover, a NET YATOZE and a sample program are introduced by the number for C Magazine (soft bank) October, 96, and there was series of the programming during several months from the November number. Although the same environment as a direct NET YAROZE does not go into a hand or these do not necessarily understand the function inside hardware, they become the key for knowing what function there is.
About more detailed information, although it is English, data analyzed by Blackbag or CREATURE-PSX or bITmASTER's PSX-Development-Page are exhibited.
Information on Japanese of the program in an assembler and some sources are exhibited for PS development note (temporary) of above-mentioned Deaf Dumb & Blind. Moreover, the signal of various controllers and data format of a memory card are analyzed by Mr. Fujita of Nifty.
The following translates, operates orthopedically and supplements with a part of data of Blackbag.
It returns with how to pass this argument, and value is completely the same as that of function call agreement of mips-gcc. Therefore, an argument (state of $ a 0-3 and a stack) is left intact, and $ t1 ($9) is set up, and if the lap function jumped to the address of a system call is introduced, it can call briefly as a function of C.
Example of a wrapper function: prototype declaration: int open (char * name, int mode); substance:(assembler) open: li $8,0xa0 #system call address .set noreorder jr $8 li $9,0 #system call number .set reorderHere, although it is using $eight for the temporaly register for a jump, if it is except the register with the necessity saving within a function, it will not care about anything. Although it is puzzling just for a moment because of delay branch of mips, if it writes plainly
li $8,0xa0 #system call address li $9,0 #system call number jr $8 #nop
When open function is called, an argument is passed to $ a0 and $ a1 like the function of usual C, and the return address is put into $ ra, and open is called. By open, then, $ a0, $ a1, and $ ra put a system call number into $ t1, and jump it to a system call. In a system call, a system call is processed from passed $ a0 and $ a1, and it returns to the place where the address, i.e. open function, of $ ra were called.
Back is easy, once it has written the wrapper function by the assembler or the in-line assembler of GCC, although knowledge of an assembler is required for this neighborhood a little.
In order to send a command to GPU, there are two, the method of sending 1 word (32 bits) every by CPU using a memory mapped I/O, and method of sending the link list of two or more packets at a stretch using DMA, and both are in a system call. The command of GPU is exhibited by above-mentioned Blackbag . It translates into Japanese here.
The pointer to packet size and the following packet is attached to the head of a packet usual in a link list.
8bit 24bit |size| next ptr | | pkt[0] | | pkt[1] | | pkt[2] | . . | pkt[size-1] |24 bits of low ranks are 24 bits of the low ranks of the address of the following packet. Since only 2 M has memory, PlayStation can be expressed enough by 24 bits (it can express up to 16M). 8 bits of highes order are size in word (32 bits) of the packet. In 0, it is the packet of the empty without substance of a packet. An end of a list is -1 (0xffffffff) probably.
It seems that analysis of SPU progresses and it has come to be already able to make sound. Register information on SPU, a wave converter, a sample code, etc. are opened to bITmASTER' s PSX-Development-Page or CREATURE-PSX . Data of CREATURE are translated here
However, since protection of hardware and software has started CD-ROM of PlayStation, neither ordinary CD-ROM, nor data of CD-R can be read by usual PlayStation.
extern long _fbss[];
extern long _end[];
extern long _gp[];
register long *gp asm("gp");
_start()
{
long *adr;
for(adr = _fbss;adr!=_end;*adr++=0);
gp = _gp;
main();
}
__main()
{
}
_start.c is compiled and _start.o is made.
mipsgcc -O2 -c _start.c
The assemble of syscall.s is carried out, and syscall.o is made.
mipsgcc -c syscall.s
#include "syscall.h" int main(int argc,char **argv) { printf("Hello,world\n"); return 0; }It saves by hello.c .
mipsgcc -O2 -Xlinker -mpsx -o hello.psx hello.c syscall.o _start.oIt comes out and compiles.
psexe hello.psxIt comes out and performs.
Apart from that, by caetla, although standard input and output of PlayStation do not exist in ? system which will be where (null device?), they are extended so that it may become the console of a host machine. Probably, it is a thing for so-called "printf debugging".
void Clear_(void) { } void gpuInit(void) { SendGPU(0); /* Some kind of reset ? */ Clear_(); SendGPU(0x03000000); /* Display Mask (enable display) */ Clear_(); SendGPU(0x06c60260); /* Screen horizontal start/end (0/256) */ Clear_(); SendGPU(0x07040010); /* Screen vertical start/end (0/240) */ Clear_(); GPU_cw(0xe1000400); /* Draw on display area / dither off / tpage0 */ Clear_(); GPU_cw(0xe3000000); /* Draw Area x, y (0,0) */ Clear_(); GPU_cw(0xe407ffff); /* Draw Area w, h (1023,511) */ Clear_(); GPU_cw(0xe5000000); /* Draw Offset (0,0) */ Clear_(); SendGPU(0x08000000); /* Display mode, 256x240/NTSC/noninterlaced */ Clear_(); }So that it may operate even when there is no Clear_ for the time being, although it considers a GPU flash or cash flash, end waiting, or something, since, it is disregarded, and it makes an empty function.
void test(void) { struct { unsigned char r0,g0,b0,code; short x0,y0; short w,h; } boxf = { 0,0,0,0x02, //black 0,0, 256,240 }; struct { unsigned char r0,g0,b0,code; short x0,y0; short x1,y1; short x2,y2; } polyF3 = { 255,0,0,0x20, //red 50,0, 0,100, 100,100 }; struct { unsigned char r0,g0,b0,code; short x0,y0; unsigned char r1,g1,b1,pad1; short x1,y1; unsigned char r2,g2,b2,pad2; short x2,y2; } polyG3 = { 255,0,0,0x30, //red 150,0, 0,255,0,0, //green 100,100, 0,0,255,0, //blue 200,100 }; GPU_cwb(&boxf,sizeof(boxf)/sizeof(long)); /* background fill */ GPU_cwb(&polyF3,sizeof(polyF3)/sizeof(long)); /* flat triangle */ GPU_cwb(&polyG3,sizeof(polyG3)/sizeof(long)); /* gouraud triangle */ } int main(int argc,char **argv) { gpuInit(); test(); for(;;) ; }Since a screen disappears when it escaped from main then and it returns to caetla, it makes not return to the infinite loop by for (;;);.
The file name passed to open is passed in the form of "a device name:file name".
device name device cdrom: CD-ROM bu00: Memory card of slot 1 bu10: Memory card of slot 2 pcdrv: Hard disk of PC (caetla extension)According to level 1 of ISO, as for the file name of CD-ROM, ";1" is attached to the end of English capital-letter 8.3 form. Though natural, it cannot write to CD-ROM.
In order to use a memory card, It seems that InitCARD(1); StartCARD(); _bu_init(); needs to be performed first. It seems that moreover, what in which the file name of a memory card had a certain law nature so that the file name of save data of each soft hat might not overlap is long is used.
In order to see information (file size etc.) and the directory of a file, a system call of firstfile/nextfile is used. This resembles the treatment of DOS or Windows. Since lseek can carry out only in block, the technique of lseeking at the file end and making the file pointer of the position file size cannot be used.
The following is the thing which rewrote the sample of the assembler of Deaf Dumb & Blind by C, and copies a file to pcdrv from CD-ROM.
Usually, if a program is created in NET YAROZE environment, it will become the thing using libps. libps consists of libps.a and libps.exe, and libps.a is linked to a program, and libps.exe is read from system CD-ROM of NET YAROZE.
The relation of libps.exe and libps.a resembles the relation of the dynamic link library (.DLL) of MS-Windows, and the import library for using DLL. Only the jump table to not the library itself but the library main part which is in libps.exe is recorded by libps.a linked to a program.
Therefore, unless there is not only a program but libps.exe, the program created by NET YAROZE does not operate. In caetla, it is transmitting libps.exe in advance, and the program of NET YAROZE can also be performed.
Some NET YAROZE members are exhibiting libps.exe with their program. Although libps.a and header files cannot receive except NET YAROZE member, since the jump table is exhibited by Mark Heath' s Home Page ,they are possible for creating the same thing.
Makefile is rewritten to CO' s gcc.
[OLD]
LINKER = -Xlinker -Ttext -Xlinker 801b0000 -Xlinker $(PROG): $(OBJS) $(CC) $(LINKER) -o $@ $?[NEW]
CC = mipsgcc LINKER = -Xlinker -Ttext -Xlinker 801b0000 -Xlinker -meco $(PROG): $(OBJS) $(CC) $(LINKER) -o $@ $? -lpsSince a batch file (A. BAT) is an object for ez-o-ray, it is rewritten to caetla.
[OLD]
del main del main.o make eco2exe -p main ez load libps.exe 8000f800 ez load picture.tim 80180000 ez run main[NEW]
del main del main.o make rem eco2exe -p main psexe -X libps.exe psexe picture.tim -d80180000 psexe mainIt performs with compile now.
It seems that the software of the foreign-countries version is made to an image at once, it substitutes for an area code of Japan, and there is also a man who is burning by CD-R and is playing the software of the foreign-countries version.
It can pass by naturally, having the portion of an area code from real CD after creating CD-R image by some self- CD-R, although this area code is not written in.
BOOT = cdrom:\POLY2D.PSX;1 TCB = 4 EVENT = 10 STACK = 801FFFF0BOOT = is the file name to start.