Everyone celebrates the new year in different ways.
Someone remembers it, and some do not.
I stood on the balcony and smoked, watching the salute. In general, I waited for the disc to be recorded.
The disc was not a pity for the sake of such an experiment - it was worth it.
It was my first PlayStation 2 application. True, all it did was to bring out the keyboard and, with the help of a joystick, type, but it was already progress!
So, launch! Works!
The very essence
So I start a series of articles on programming for the PlayStation 2
First there will be a long theory.
Then practice. Since I am not a professional C ++ (or C - as you like, but I will tell in C ++), I ask you not to judge the code strictly.
Also, on the PlayStation 2 SDK, it is advisable to use Red Hat 6 or higher, however, I am writing all this under Windows 7. Although everything works crookedly, it works - and it’s ok.
By the beginning of practical experiments, I advise you to have a PlayStation 2 chipset and a power cable. For my experiments, the PlayStation 2 Slim 90006 format of NTSC chip card and blue network cable were selected =) (I did not use iLink mode for debugging, since the drivers are bundled only for Linux, and I also need a hard disk).
')
Officially
Naturally, your games will not be official. Even sure that Sony may not forgive such slop. Officially, you can buy support, the SDK itself and the equipment of everything, you wouldn’t lie for $ 10,000. Yes, and not everyone is licensed ...
We are not rich people, so we will go the way ...
Unofficially
Unofficially, I searched for this SDK for several days, I downloaded it for two weeks (and maybe more), I understood even more in the pile of docks. At the moment, the SDK is 608 meters, including software, without Visual Studio 6.
So. To begin with, we will have to go through 13 simple chapters (only in some I still have questions that I still understand, for example, a memory card).
Chapters I am going to tell in the following order:
Controller Library (chapters two are about the joystick and multitap);
CD (DVD) -ROM Library (games can be both on CD and on DVD);
Memory Card Library. (memory card. There are two chapters and they are very difficult to understand);
PS2 Memory Card FileSystem (FAT file system of the memory card);
EE Kernel (the most hemorrhoid theme, but worth knowing);
Graphic Library (it will be a long time, but many will wait for this article - I am sure);
Sound Library (too many);
Movie Library (MPEG and IPU);
Network Library (work with the network and everything connected with it);
Hard Disk Library (I don’t have a hard disk, so I’ll only talk about it in theory);
Basic requirements
Pentium 3, the FIG knows how much RAM, but I think 500 meters is enough.
At a certain point, when it will be possible to quit the theory, I’ll post the PlayStation 2 SDK (they didn’t get a penny, but it’sn’t like writing).
Also, at a certain point, I will begin to study with you, since I have not mastered all the information so far. I suggest, so far, just write, but as it will, I will lay out the SDK and it will be possible to combine.
I use Metrowerks CodeWarrior 4.2.6.844. Alas, the PS2 SDK got up just fine there. The compiler is GCC or Visual Studio 6.
For information and those who "can do everything"
Linux is used on PS2. If my guesses are correct, then this “something” reminds me of Red Hat. Naturally, all files and commands are case sensitive.
You can use threads, but there is only one processor - ARM.
As you understand, it is necessary to work with bytes. For example, this is what the response to the request for threads includes (type -
DBGP_EE_THREADLIST_DATA ):
- Id - stream ID
- Priority is his priority
- Status - status of the stream, which may include the following types:
- THS_RUN = 0x01 // running
- THS_READY = 0x02 // ready
- THS_WAIT = 0x04 // pending
- THS_SUSPEND = 0x08 // suspended
- THS_WAITSUSPEND = 0xc // pending suspension (for me this is generally a secret secret)
- THS_DORMANT = 0x10 // idle thread
- Cause - actually the reason for the wait: 0 - none, 1 - sleep, 2 - sema (ie, semaphore)
- Waited - semaphore ID
- Wakeupcount - the number of wake-up requests
- Count - the number of times the thread entered the RUN state
- Pc - Team Counter
- Sp - A pointer to the top of the stack $ 29 (thanks Maccimo )
- Func - Address of Execution Point
- Ra - Return Point Address $ 31
- reserved [0] - reserved infa
- reserved [1] - Reserved infa.
Oh yes, if the thread is in the RUN state, then the pc, sp, and ra are the current values.
As you can see, programming on PS2 is not an easy task. It can only be compared with PC programming by language and standard function calls. Naturally, you need to save on memory. Excess need to unload. If you want to read something from the disk - you need to move the head directly before reading - the information may become irrelevant. This is a very difficult programming, so evaluate your strength really.
In general, until the next article. I will try to lay out quickly ...
PS : I apologize for not being able to upload the PS2 SDK now. But I hope everything will be in the next article.
Update : I started writing the first article and remembered.
I forgot to specify that a regular makefile is used.
It looks something like this (taken from the first example for the joystick):
SHELL = /bin/sh
TOP = /usr/local/sce/ee
LIBDIR = $(TOP)/lib
INCDIR = $(TOP)/include
TARGET = main
OBJS = crt0.o \
$(TARGET).o
LCFILE = $(LIBDIR)/app.cmd
LIBS = $(LIBDIR)/libgraph.a \
$(LIBDIR)/libdma.a \
$(LIBDIR)/libdev.a \
$(LIBDIR)/libpkt.a \
$(LIBDIR)/libkernl.a \
$(LIBDIR)/libpad.a
PREFIX = ee
AS = $(PREFIX)-gcc
CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc
DVPASM = $(PREFIX)-dvp-as
OBJDUMP = $(PREFIX)-objdump
RUN = dsedb -r run
RM = /bin/rm -f
CFLAGS = -O2 -Wall -Wa,-al -fno-common
CXXFLAGS = -O2 -Wall -Werror -Wa,-al -fno-exceptions -fno-common
ASFLAGS = -c -xassembler-with-cpp -Wa,-al
DVPASMFLAGS = -g
LDFLAGS = -Wl,-Map,$(TARGET).map -mno-crt0 -L$(LIBDIR) -lm
TMPFLAGS =
.SUFFIXES: .c .s .cc .dsm
all: $(TARGET).elf
$(TARGET).elf: $(OBJS) $(LIBS)
$(LD) -o $@ -T $(LCFILE) $(OBJS) $(LIBS) $(LDFLAGS)
crt0.o: $(LIBDIR)/crt0.s
$(AS) $(ASFLAGS) $(TMPFLAGS) -o $@ $< > $*.lst
.so:
$(AS) $(ASFLAGS) $(TMPFLAGS) -I$(INCDIR) -o $@ $< > $*.lst
.dsm.o:
$(DVPASM) $(DVPASMFLAGS) -I$(INCDIR) -o $@ $< > $*.lst
.co:
$(CC) $(CFLAGS) $(TMPFLAGS) -I$(INCDIR) -c $< -o $*.o > $*.lst
.cc.o:
$(CC) $(CXXFLAGS) $(TMPFLAGS) -I$(INCDIR) -c $< -o $*.o > $*.lst
run: $(TARGET).elf
$(RUN) $(TARGET).elf
clean:
$(RM) *.o *.map *.lst core *.dis *.elf
Your program works with the main function.
Your code should work in an infinite loop, i.e. an empty project looks like this:
#include #include <mwutils.h>
//
int main (void);
int main (void)
{
while(1){
//
}
return 0;
}