first commit

This commit is contained in:
Dan Peori
2010-10-18 12:54:49 -03:00
commit 8a3bef9012
612 changed files with 74685 additions and 0 deletions

28
LICENSE Normal file
View File

@@ -0,0 +1,28 @@
Copyright (c) 2005 adresd
Copyright (c) 2005 Marcus R. Brown
Copyright (c) 2005 James Forshaw
Copyright (c) 2005 John Kelley
Copyright (c) 2005 Jesper Svennevid
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

18
Makefile.am Normal file
View File

@@ -0,0 +1,18 @@
ACLOCAL_AMFLAGS = -I aclocal
ACLOCAL_FILES = aclocal/version.m4 aclocal/pspdev.m4 aclocal/ac_doxygen.m4
SUBDIRS = src tools
include aminclude.am
MOSTLYCLEANFILES = $(DX_CLEANFILES)
EXTRA_DIST = \
$(ACLOCAL_FILES) \
LICENSE \
VERSION \
$(DX_CONFIG) \
doc/html
dist-hook:
rm -rf `find $(distdir)/doc/html/* -name .svn -o -name CVS`

216
README Normal file
View File

@@ -0,0 +1,216 @@
PSP Software Development Kit
Version 1.0+beta2
http://www.pspdev.org/
Introduction
The PSP Software Development Kit (PSPSDK) is a collection of Open Source
tools and libraries written for Sony's Playstation Portable (PSP) gaming
console. It also includes documentation and other resources developers can
use to write software for the PSP.
PSPSDK is distributed under a BSD-compatible license. See the LICENSE
file for more information.
Features
PSPSDK provides a full set of libraries for creating PSP software:
* Stub libraries and headers for interfacing with the PSP operating
system, ranging from threading libraries, file io, display driver
and wifi networking.
* Basic runtime support (crt0) for executables and libraries.
* A minimal port of the Standard C Library (libc) is included. PSPSDK's
mini-libc provides portable memory allocation, string formatting, and
several other Standard C Library functions.
* Support code for linking with the full Standard C Library provided with
the PSPDEV toolchain.
* An implementation of the libGU graphics library. libGU provides an
interface to the 2D and 3D hardware acceleration features found in the
PSP's Graphic Engine.
* An implementation of the libGUM library. libGUM provides an interface
for manipulating matrices for use in 3D software.
* A simple audio library which can be used to play back PCM audio streams.
* Support for building static executables and PRX files (relocatable
modules).
PSPSDK also includes several tools to assist in building PSP software:
* bin2c, bin2o, and bin2s for converting binary files into C source,
object files, and assembler source files, respectively.
* mksfo for creating PARAM.SFO files.
* pack-pbp and unpack-pbp for adding files to and removing files from
EBOOT.PBP.
* psp-config for locating PSPDEV tools and libraries.
* psp-prxgen for converting specially made ELFs to PRX files.
* psp-build-exports for creating export tables
* psp-fixup-imports for fixing up import tables post-linking to remove
unused functions from the executable.
Documentation for the libraries are also provided, and can be found in the
doc/ directory of the PSPSDK source and binary distributions.
A library for Make (build.mak) is also included to provide an easy way to
build simple programs and libraries. See any PSPSDK sample program for
details on how build.mak is used.
Installation
PSPSDK is distributed in both source and binary packages. If you only
want to use the PSPSDK tools and libraries to develop your software you'll
want to grab the binary distribution of PSPSDK specific to your development
platform. If you need fine-grained control over how PSPSDK is installed on
your system, or if you would like to modify PSPSDK then grab the source
distribution. You can also install PSPSDK from Subversion, see "Installation
from Subversion" below for details.
Requirements
To use PSPSDK you must have the following software installed:
* The PSPDEV Toolchain. PSPSDK requires the GNU toolchain (GCC and
binutils) targetted to the PSP. You can find binary packages of these
tools at http://www.pspdev.org/. You can find a script to build and
install the toolchain at http://www.oopo.net/consoledev/.
In addition to the above requirements, if you plan on building PSPSDK from
source, you will need:
* Make. Note: GNU Make may not be required, but if you run into problems
building from source you may want to install it. You can find GNU Make
at http://www.gnu.org/software/make/.
If you plan on building PSPSDK directly from the Subversion repository you
will need:
* A Subversion client. A popular client for Windows is TortoiseSVN
(http://tortoisesvn.tigris.org/).
* GNU autotools. You will need a recent version of autoconf
(http://www.gnu.org/software/autoconf/) and automake
(http://sourceware.org/automake/).
The following packages are not required to build PSPSDK, but are used to
build documentation and other optional resources:
* Doxygen. You can find Doxygen at http://www.stack.nl/~dimitri/doxygen/.
If you want to view the pretty source dependency graphs, then you will
also need to install Graphviz (http://www.graphviz.org/).
Installation from binary
Download the PSPSDK binary package specific to your development system.
For example, if you are using Windows, you will want to download the file
pspsdk-1.0-win32.zip.
Extract or unzip the package into the folder where the PSPDEV toolchain is
installed. For example, on a Windows system you may have installed the PSPDEV
toolchain to C:\pspdev. You would then unzip PSPSDK into C:\pspdev.
Update your PATH environment variable to point to the PSPSDK tools
directory. In the above example, if you installed PSPSDK to C:\pspdev, you
would add C:\pspdev\bin to your PATH.
Installation from source
PSPSDK uses the GNU autotools (autoconf and automake) for its build
system. To install PSPSDK from a source distribution, run the following
commands after unpacking it:
./configure
make
make doxygen-doc
make install
If you haven't installed Doxygen or don't want to build the library
documentation, you can skip the
Installation from Subversion
PSPSDK can be found in the Subversion repository located at
svn://svn.pspdev.org/psp. If you are using the command line version of the
Subversion client, you can the following command to download PSPSDK:
svn co svn://svn.pspdev.org/psp/trunk/pspsdk
Once you've downloaded PSPSDK, run the following from the pspsdk directory
to create the configure script and support files (you must have autoconf and
automake installed):
./bootstrap
You can now run the commands listed in the "Installation from source"
section.
Notes
* This is a BETA release of PSPSDK. Some of the features and tools
described here may not be fully implemented.
* By default PSPSDK will install into the directory where the PSPDEV
toolchain is installed. If you decide to install PSPSDK somewhere else
then you must define a PSPSDK environment variable that points to your
alternate directory. The psp-config build utility will look for PSPSDK
in the location specified in the PSPSDK environment variable first, or
use its own location to determine where PSPSDK is installed.
* The Makefile templates provided by the sample code are designed for
building a single executable or a library, but not both. If you plan on
using these templates in your project to build both libraries
and executables be aware that you will have to structure your project so
that each library and executable are built in a seperate directory.
Bugs
If you find a bug in PSPSDK, send an e-mail describing the bug to
pspsdk-bugs@lists.ps2dev.org. If possible, include any code or documentation
that can be used by the PSPSDK developers to recreate the bug.
Resources
Mailing Lists
pspsdk-bugs@lists.ps2dev.org
Use this list to report any bugs you find in PSPSDK. To subscribe, send an
empty e-mail message to pspsdk-bugs-subscribe@lists.ps2dev.org.
For a full list of PSP development mailing lists, see
http://lists.ps2dev.org/.
Web Forums
http://forums.ps2dev.org/
The PSP development forums are an excellent place to find out about the
latest PSP homebrew games, demos, and other software. PSPSDK has it's own
dedicated forum titled 'PSPSDK Support and Development'. Use this forum to
find out about the most recent PSPSDK developments and to ask questions
about PSPSDK.
Subversion
svn://svn.pspdev.org/
http://svn.pspdev.org/
PSPDEV tools and libraries can be found in the psp/ repository at
svn://svn.pspdev.org/. PSP homebrew games, demos, and other applications
can be found in the pspware/ repository located at the same URL. To view
the contents of these repositories using a Web browser, visit
http://svn.pspdev.org/.
Internet Relay Chat (IRC)
The PSPSDK developers can be found hanging out in the #pspdev channel
on irc.freenode.net.
Thanks
The pspsdk developers wish to thank all the people who have contributed
bug fixes, ideas and support for the project.
Also big thanks to nem for kicking off PSP development with all his work,
the original imports system is based on his work in the hello world demo.

1
VERSION Normal file
View File

@@ -0,0 +1 @@
1.0+beta2

312
aclocal/ac_doxygen.m4 Normal file
View File

@@ -0,0 +1,312 @@
# This file is part of Autoconf. -*- Autoconf -*-
# Copyright (C) 2004 Oren Ben-Kiki
# This file is distributed under the same terms as the Autoconf macro files.
# Generate automatic documentation using Doxygen. Works in concert with the
# aminclude.m4 file and a compatible doxygen configuration file. Defines the
# following public macros:
#
# DX_???_FEATURE(ON|OFF) - control the default setting fo a Doxygen feature.
# Supported features are 'DOXYGEN' itself, 'DOT' for generating graphics,
# 'HTML' for plain HTML, 'CHM' for compressed HTML help (for MS users), 'CHI'
# for generating a seperate .chi file by the .chm file, and 'MAN', 'RTF',
# 'XML', 'PDF' and 'PS' for the appropriate output formats. The environment
# variable DOXYGEN_PAPER_SIZE may be specified to override the default 'a4wide'
# paper size.
#
# By default, HTML, PDF and PS documentation is generated as this seems to be
# the most popular and portable combination. MAN pages created by Doxygen are
# usually problematic, though by picking an appropriate subset and doing some
# massaging they might be better than nothing. CHM and RTF are specific for MS
# (note that you can't generate both HTML and CHM at the same time). The XML is
# rather useless unless you apply specialized post-processing to it.
#
# The macro mainly controls the default state of the feature. The use can
# override the default by specifying --enable or --disable. The macros ensure
# that contradictory flags are not given (e.g., --enable-doxygen-html and
# --enable-doxygen-chm, --enable-doxygen-anything with --disable-doxygen, etc.)
# Finally, each feature will be automatically disabled (with a warning) if the
# required programs are missing.
#
# Once all the feature defaults have been specified, call DX_INIT_DOXYGEN with
# the following parameters: a one-word name for the project for use as a
# filename base etc., an optional configuration file name (the default is
# 'Doxyfile', the same as Doxygen's default), and an optional output directory
# name (the default is 'doxygen-doc').
## ----------##
## Defaults. ##
## ----------##
DX_ENV=""
AC_DEFUN([DX_FEATURE_doc], ON)
AC_DEFUN([DX_FEATURE_dot], ON)
AC_DEFUN([DX_FEATURE_man], OFF)
AC_DEFUN([DX_FEATURE_html], ON)
AC_DEFUN([DX_FEATURE_chm], OFF)
AC_DEFUN([DX_FEATURE_chi], OFF)
AC_DEFUN([DX_FEATURE_rtf], OFF)
AC_DEFUN([DX_FEATURE_xml], OFF)
AC_DEFUN([DX_FEATURE_pdf], ON)
AC_DEFUN([DX_FEATURE_ps], ON)
## --------------- ##
## Private macros. ##
## --------------- ##
# DX_ENV_APPEND(VARIABLE, VALUE)
# ------------------------------
# Append VARIABLE="VALUE" to DX_ENV for invoking doxygen.
AC_DEFUN([DX_ENV_APPEND], [AC_SUBST([DX_ENV], ["$DX_ENV $1='$2'"])])
# DX_DIRNAME_EXPR
# ---------------
# Expand into a shell expression prints the directory part of a path.
AC_DEFUN([DX_DIRNAME_EXPR],
[[expr ".$1" : '\(\.\)[^/]*$' \| "x$1" : 'x\(.*\)/[^/]*$']])
# DX_IF_FEATURE(FEATURE, IF-ON, IF-OFF)
# -------------------------------------
# Expands according to the M4 (static) status of the feature.
AC_DEFUN([DX_IF_FEATURE], [ifelse(DX_FEATURE_$1, ON, [$2], [$3])])
# DX_REQUIRE_PROG(VARIABLE, PROGRAM)
# ----------------------------------
# Require the specified program to be found for the DX_CURRENT_FEATURE to work.
AC_DEFUN([DX_REQUIRE_PROG], [
AC_PATH_TOOL([$1], [$2])
if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
fi
])
# DX_TEST_FEATURE(FEATURE)
# ------------------------
# Expand to a shell expression testing whether the feature is active.
AC_DEFUN([DX_TEST_FEATURE], [test "$DX_FLAG_$1" = 1])
# DX_CHECK_DEPEND(REQUIRED_FEATURE, REQUIRED_STATE)
# -------------------------------------------------
# Verify that a required features has the right state before trying to turn on
# the DX_CURRENT_FEATURE.
AC_DEFUN([DX_CHECK_DEPEND], [
test "$DX_FLAG_$1" = "$2" \
|| AC_MSG_ERROR([doxygen-DX_CURRENT_FEATURE ifelse([$2], 1,
requires, contradicts) doxygen-DX_CURRENT_FEATURE])
])
# DX_CLEAR_DEPEND(FEATURE, REQUIRED_FEATURE, REQUIRED_STATE)
# ----------------------------------------------------------
# Turn off the DX_CURRENT_FEATURE if the required feature is off.
AC_DEFUN([DX_CLEAR_DEPEND], [
test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
])
# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
# CHECK_DEPEND, CLEAR_DEPEND,
# REQUIRE, DO-IF-ON, DO-IF-OFF)
# --------------------------------------------
# Parse the command-line option controlling a feature. CHECK_DEPEND is called
# if the user explicitly turns the feature on (and invokes DX_CHECK_DEPEND),
# otherwise CLEAR_DEPEND is called to turn off the default state if a required
# feature is disabled (using DX_CLEAR_DEPEND). REQUIRE performs additional
# requirement tests (DX_REQUIRE_PROG). Finally, an automake flag is set and
# DO-IF-ON or DO-IF-OFF are called according to the final state of the feature.
AC_DEFUN([DX_ARG_ABLE], [
AC_DEFUN([DX_CURRENT_FEATURE], [$1])
AC_DEFUN([DX_CURRENT_DESCRIPTION], [$2])
AC_ARG_ENABLE(doxygen-$1,
[AS_HELP_STRING(DX_IF_FEATURE([$1], [--disable-doxygen-$1],
[--enable-doxygen-$1]),
DX_IF_FEATURE([$1], [don't $2], [$2]))],
[
case "$enableval" in
#(
y|Y|yes|Yes|YES)
AC_SUBST([DX_FLAG_$1], 1)
$3
;; #(
n|N|no|No|NO)
AC_SUBST([DX_FLAG_$1], 0)
;; #(
*)
AC_MSG_ERROR([invalid value '$enableval' given to doxygen-$1])
;;
esac
], [
AC_SUBST([DX_FLAG_$1], [DX_IF_FEATURE([$1], 1, 0)])
$4
])
if DX_TEST_FEATURE([$1]); then
$5
:
fi
if DX_TEST_FEATURE([$1]); then
AM_CONDITIONAL(DX_COND_$1, :)
$6
:
else
AM_CONDITIONAL(DX_COND_$1, false)
$7
:
fi
])
## -------------- ##
## Public macros. ##
## -------------- ##
# DX_XXX_FEATURE(DEFAULT_STATE)
# -----------------------------
AC_DEFUN([DX_DOXYGEN_FEATURE], [AC_DEFUN([DX_FEATURE_doc], [$1])])
AC_DEFUN([DX_MAN_FEATURE], [AC_DEFUN([DX_FEATURE_man], [$1])])
AC_DEFUN([DX_HTML_FEATURE], [AC_DEFUN([DX_FEATURE_html], [$1])])
AC_DEFUN([DX_CHM_FEATURE], [AC_DEFUN([DX_FEATURE_chm], [$1])])
AC_DEFUN([DX_CHI_FEATURE], [AC_DEFUN([DX_FEATURE_chi], [$1])])
AC_DEFUN([DX_RTF_FEATURE], [AC_DEFUN([DX_FEATURE_rtf], [$1])])
AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])])
AC_DEFUN([DX_XML_FEATURE], [AC_DEFUN([DX_FEATURE_xml], [$1])])
AC_DEFUN([DX_PDF_FEATURE], [AC_DEFUN([DX_FEATURE_pdf], [$1])])
AC_DEFUN([DX_PS_FEATURE], [AC_DEFUN([DX_FEATURE_ps], [$1])])
# DX_INIT_DOXYGEN(PROJECT, [CONFIG-FILE], [OUTPUT-DOC-DIR])
# ---------------------------------------------------------
# PROJECT also serves as the base name for the documentation files.
# The default CONFIG-FILE is "Doxyfile" and OUTPUT-DOC-DIR is "doxygen-doc".
AC_DEFUN([DX_INIT_DOXYGEN], [
# Files:
AC_SUBST([DX_PROJECT], [$1])
AC_SUBST([DX_CONFIG], [ifelse([$2], [], Doxyfile, [$2])])
AC_SUBST([DX_DOCDIR], [ifelse([$3], [], doxygen-doc, [$3])])
# Environment variables used inside doxygen.cfg:
DX_ENV_APPEND(SRCDIR, $srcdir)
DX_ENV_APPEND(PROJECT, $DX_PROJECT)
DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
DX_ENV_APPEND(VERSION, $PACKAGE_VERSION)
# Doxygen itself:
DX_ARG_ABLE(doc, [generate any doxygen documentation],
[],
[],
[DX_REQUIRE_PROG([DX_DOXYGEN], doxygen)
DX_REQUIRE_PROG([DX_PERL], perl)],
[DX_ENV_APPEND(PERL_PATH, $DX_PERL)])
# Dot for graphics:
DX_ARG_ABLE(dot, [generate graphics for doxygen documentation],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[DX_REQUIRE_PROG([DX_DOT], dot)],
[DX_ENV_APPEND(HAVE_DOT, YES)
DX_ENV_APPEND(DOT_PATH, [`DX_DIRNAME_EXPR($DX_DOT)`])],
[DX_ENV_APPEND(HAVE_DOT, NO)])
# Man pages generation:
DX_ARG_ABLE(man, [generate doxygen manual pages],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[],
[DX_ENV_APPEND(GENERATE_MAN, YES)],
[DX_ENV_APPEND(GENERATE_MAN, NO)])
# RTF file generation:
DX_ARG_ABLE(rtf, [generate doxygen RTF documentation],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[],
[DX_ENV_APPEND(GENERATE_RTF, YES)],
[DX_ENV_APPEND(GENERATE_RTF, NO)])
# XML file generation:
DX_ARG_ABLE(xml, [generate doxygen XML documentation],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[],
[DX_ENV_APPEND(GENERATE_XML, YES)],
[DX_ENV_APPEND(GENERATE_XML, NO)])
# (Compressed) HTML help generation:
DX_ARG_ABLE(chm, [generate doxygen compressed HTML help documentation],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[DX_REQUIRE_PROG([DX_HHC], hhc)],
[DX_ENV_APPEND(HHC_PATH, $DX_HHC)
DX_ENV_APPEND(GENERATE_HTML, YES)
DX_ENV_APPEND(GENERATE_HTMLHELP, YES)],
[DX_ENV_APPEND(GENERATE_HTMLHELP, NO)])
# Seperate CHI file generation.
DX_ARG_ABLE(chi, [generate doxygen seperate compressed HTML help index file],
[DX_CHECK_DEPEND(chm, 1)],
[DX_CLEAR_DEPEND(chm, 1)],
[],
[DX_ENV_APPEND(GENERATE_CHI, YES)],
[DX_ENV_APPEND(GENERATE_CHI, NO)])
# Plain HTML pages generation:
DX_ARG_ABLE(html, [generate doxygen plain HTML documentation],
[DX_CHECK_DEPEND(doc, 1) DX_CHECK_DEPEND(chm, 0)],
[DX_CLEAR_DEPEND(doc, 1) DX_CLEAR_DEPEND(chm, 0)],
[],
[DX_ENV_APPEND(GENERATE_HTML, YES)],
[DX_TEST_FEATURE(chm) || DX_ENV_APPEND(GENERATE_HTML, NO)])
# PostScript file generation:
DX_ARG_ABLE(ps, [generate doxygen PostScript documentation],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[DX_REQUIRE_PROG([DX_LATEX], latex)
DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
DX_REQUIRE_PROG([DX_DVIPS], dvips)
DX_REQUIRE_PROG([DX_EGREP], egrep)])
# PDF file generation:
DX_ARG_ABLE(pdf, [generate doxygen PDF documentation],
[DX_CHECK_DEPEND(doc, 1)],
[DX_CLEAR_DEPEND(doc, 1)],
[DX_REQUIRE_PROG([DX_PDFLATEX], pdflatex)
DX_REQUIRE_PROG([DX_MAKEINDEX], makeindex)
DX_REQUIRE_PROG([DX_EGREP], egrep)])
# LaTeX generation for PS and/or PDF:
if DX_TEST_FEATURE(ps) || DX_TEST_FEATURE(pdf); then
AM_CONDITIONAL(DX_COND_latex, :)
DX_ENV_APPEND(GENERATE_LATEX, YES)
else
AM_CONDITIONAL(DX_COND_latex, false)
DX_ENV_APPEND(GENERATE_LATEX, NO)
fi
# Paper size for PS and/or PDF:
AC_ARG_VAR(DOXYGEN_PAPER_SIZE,
[a4wide (default), a4, letter, legal or executive])
case "$DOXYGEN_PAPER_SIZE" in
#(
"")
AC_SUBST(DOXYGEN_PAPER_SIZE, "")
;; #(
a4wide|a4|letter|legal|executive)
DX_ENV_APPEND(PAPER_SIZE, $DOXYGEN_PAPER_SIZE)
;; #(
*)
AC_MSG_ERROR([unknown DOXYGEN_PAPER_SIZE='$DOXYGEN_PAPER_SIZE'])
;;
esac
#For debugging:
#echo DX_FLAG_doc=$DX_FLAG_doc
#echo DX_FLAG_dot=$DX_FLAG_dot
#echo DX_FLAG_man=$DX_FLAG_man
#echo DX_FLAG_html=$DX_FLAG_html
#echo DX_FLAG_chm=$DX_FLAG_chm
#echo DX_FLAG_chi=$DX_FLAG_chi
#echo DX_FLAG_rtf=$DX_FLAG_rtf
#echo DX_FLAG_xml=$DX_FLAG_xml
#echo DX_FLAG_pdf=$DX_FLAG_pdf
#echo DX_FLAG_ps=$DX_FLAG_ps
#echo DX_ENV=$DX_ENV
])

61
aclocal/pspdev.m4 Normal file
View File

@@ -0,0 +1,61 @@
dnl
dnl AC_PSPDEV_PATH()
dnl
dnl Check for a valid pspdev installation.
AC_DEFUN([AC_PSPDEV_PATH],
[
AC_ARG_WITH(pspdev,
[ --with-pspdev=DIR Path where the pspdev toolchain is installed (default is $PSPDEV)],
pspdev="$withval", pspdev="$PSPDEV")
AC_MSG_CHECKING(for pspdev)
if test x$pspdev = x ; then
# If there's no $PSPDEV environment variable, find out where psp-gcc lives (it should be on the $PATH).
psp_gcc_path=`which psp-gcc`
if test x$psp_gcc_path = x ; then
AC_MSG_ERROR(can't find the pspdev toolchain. Use --with-pspdev or set PSPDEV)
fi
# Strip both the /psp-gcc and /bin portions from the path.
pspdev=`echo $psp_gcc_path | sed 's/\/psp-gcc//' | sed 's/\/bin//'`
fi
AC_MSG_RESULT($pspdev)
PSPDEV="$pspdev"
AC_SUBST(PSPDEV)
# Fill out a few common directories for things that need it.
# Note: if we ever decide to support more than just the "psp" prefix, these will have to be updated.
pspdev_includedir="$pspdev/psp/include"
pspdev_libdir="$pspdev/psp/lib"
PSPDEV_INCLUDEDIR="$pspdev_includedir"
PSPDEV_LIBDIR="$pspdev_libdir"
AC_SUBST(PSPDEV_INCLUDEDIR)
AC_SUBST(PSPDEV_LIBDIR)
])
dnl Check for a tool prefixed with "psp-".
dnl __PSPDEV_CHECK_TOOL(VARIABLE, PREFIX, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH]])
AC_DEFUN([__PSPDEV_CHECK_TOOL],
[
pspdev_tool_prefix="psp-"
AC_CHECK_PROG($1, ${pspdev_tool_prefix}$2, ${pspdev_tool_prefix}$2, $3, $4)
])
dnl
dnl AC_PSPDEV_TOOLCHAIN()
dnl
dnl Make sure all of the required pspdev tools exist.
dnl TODO: This could be made more robust just in case someone installs the tools wihthout
dnl the psp- prefix. That's highly unlikely though.
AC_DEFUN([AC_PSPDEV_TOOLCHAIN],
[
__PSPDEV_CHECK_TOOL(PSP_CC, gcc, psp-gcc)
__PSPDEV_CHECK_TOOL(PSP_CXX, g++, psp-g++)
__PSPDEV_CHECK_TOOL(PSP_AS, as, psp-as)
__PSPDEV_CHECK_TOOL(PSP_LD, ld, psp-ld)
__PSPDEV_CHECK_TOOL(PSP_AR, ar, psp-ar)
__PSPDEV_CHECK_TOOL(PSP_NM, nm, psp-nm)
__PSPDEV_CHECK_TOOL(PSP_RANLIB, ranlib, psp-ranlib)
])

19
aclocal/version.m4 Normal file
View File

@@ -0,0 +1,19 @@
dnl
dnl AC_PSPSDK_VERSION()
dnl
dnl Determine the pspsdk package version.
AC_DEFUN([AC_PSPSDK_VERSION],
[
AC_BEFORE([$0], [AM_INIT_AUTOMAKE])
AC_MSG_CHECKING([for pspsdk version])
AS_IF([test -r "${srcdir}/aclocal/version.m4"],
[],
[AC_MSG_ERROR([Unable to find aclocal/version.m4])])
AS_IF([test -r "${srcdir}/VERSION"],
[],
[AC_MSG_ERROR([Unable to find VERSION])])
pspsdk_version=`cat "${srcdir}/VERSION"`
AC_MSG_RESULT($pspsdk_version)
])

186
aminclude.am Normal file
View File

@@ -0,0 +1,186 @@
# Copyright (C) 2004 Oren Ben-Kiki
# This file is distributed under the same terms as the Automake macro files.
# Generate automatic documentation using Doxygen. Goals and variables values
# are controlled by the various DX_COND_??? conditionals set by autoconf.
#
# The provided goals are:
# doxygen-doc: Generate all doxygen documentation.
# doxygen-run: Run doxygen, which will generate some of the documentation
# (HTML, CHM, CHI, MAN, RTF, XML) but will not do the post
# processing required for the rest of it (PS, PDF, and some MAN).
# doxygen-man: Rename some doxygen generated man pages.
# doxygen-ps: Generate doxygen PostScript documentation.
# doxygen-pdf: Generate doxygen PDF documentation.
#
# Note that by default these are not integrated into the automake goals. If
# doxygen is used to generate man pages, you can achieve this integration by
# setting man3_MANS to the list of man pages generated and then adding the
# dependency:
#
# $(man3_MANS): doxygen-doc
#
# This will cause make to run doxygen and generate all the documentation.
#
# The following variable is intended for use in Makefile.am:
#
# DX_CLEANFILES = everything to clean.
#
# This is usually added to MOSTLYCLEANFILES.
## --------------------------------- ##
## Format-independent Doxygen rules. ##
## --------------------------------- ##
if DX_COND_doc
## ------------------------------- ##
## Rules specific for HTML output. ##
## ------------------------------- ##
if DX_COND_html
DX_CLEAN_HTML = @DX_DOCDIR@/html
endif DX_COND_html
## ------------------------------ ##
## Rules specific for CHM output. ##
## ------------------------------ ##
if DX_COND_chm
DX_CLEAN_CHM = @DX_DOCDIR@/chm
if DX_COND_chi
DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi
endif DX_COND_chi
endif DX_COND_chm
## ------------------------------ ##
## Rules specific for MAN output. ##
## ------------------------------ ##
if DX_COND_man
DX_CLEAN_MAN = @DX_DOCDIR@/man
endif DX_COND_man
## ------------------------------ ##
## Rules specific for RTF output. ##
## ------------------------------ ##
if DX_COND_rtf
DX_CLEAN_RTF = @DX_DOCDIR@/rtf
endif DX_COND_rtf
## ------------------------------ ##
## Rules specific for XML output. ##
## ------------------------------ ##
if DX_COND_xml
DX_CLEAN_XML = @DX_DOCDIR@/xml
endif DX_COND_xml
## ----------------------------- ##
## Rules specific for PS output. ##
## ----------------------------- ##
if DX_COND_ps
DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps
DX_PS_GOAL = doxygen-ps
doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps
@DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag
cd @DX_DOCDIR@/latex; \
rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
$(DX_LATEX) refman.tex; \
$(MAKEINDEX_PATH) refman.idx; \
$(DX_LATEX) refman.tex; \
countdown=5; \
while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
refman.log > /dev/null 2>&1 \
&& test $$countdown -gt 0; do \
$(DX_LATEX) refman.tex; \
countdown=`expr $$countdown - 1`; \
done; \
$(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi
endif DX_COND_ps
## ------------------------------ ##
## Rules specific for PDF output. ##
## ------------------------------ ##
if DX_COND_pdf
DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf
DX_PDF_GOAL = doxygen-pdf
doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf
@DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag
cd @DX_DOCDIR@/latex; \
rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
$(DX_PDFLATEX) refman.tex; \
$(DX_MAKEINDEX) refman.idx; \
$(DX_PDFLATEX) refman.tex; \
countdown=5; \
while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
refman.log > /dev/null 2>&1 \
&& test $$countdown -gt 0; do \
$(DX_PDFLATEX) refman.tex; \
countdown=`expr $$countdown - 1`; \
done; \
mv refman.pdf ../@PACKAGE@.pdf
endif DX_COND_pdf
## ------------------------------------------------- ##
## Rules specific for LaTeX (shared for PS and PDF). ##
## ------------------------------------------------- ##
if DX_COND_latex
DX_CLEAN_LATEX = @DX_DOCDIR@/latex
endif DX_COND_latex
.PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL)
.INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag
doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
@DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS)
# rm -rf @DX_DOCDIR@
$(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG)
DX_CLEANFILES = \
@DX_DOCDIR@/@PACKAGE@.tag \
-r \
$(DX_CLEAN_HTML) \
$(DX_CLEAN_CHM) \
$(DX_CLEAN_CHI) \
$(DX_CLEAN_MAN) \
$(DX_CLEAN_RTF) \
$(DX_CLEAN_XML) \
$(DX_CLEAN_PS) \
$(DX_CLEAN_PDF) \
$(DX_CLEAN_LATEX)
endif DX_COND_doc

137
bootstrap Executable file
View File

@@ -0,0 +1,137 @@
#!/bin/sh
# PSP Software Development Kit - http://www.pspdev.org
# -----------------------------------------------------------------------
# Licensed under the BSD license, see LICENSE in PSPSDK root for details.
#
# bootstrap - Script to bootstrap GNU autoconf and GNU automake.
# Inspired by libtool's autogen script.
#
# Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
# Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
# Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
#$Id: bootstrap 444 2005-07-03 20:34:12Z mrbrown $
progname=`basename $0`
top_srcdir=`dirname $0`
verbose="";
quiet="false"
mode="generate"
usage()
{
echo
echo "usage: ${progname} [-h|-q|-v|-c]"
echo
echo "options:"
echo " -h .. display this message and exit";
echo " -q .. quiet, don't display directories";
echo " -v .. verbose, pass -v to automake when invoking automake"
echo " -c .. clean, remove all aclocal/autoconf/automake generated files"
echo
exit 1;
}
if test ! -f $top_srcdir/VERSION; then
echo "${progname}:"
echo " Installation problem: Can't find file VERSION"
exit 1;
fi
while test $# -gt 0; do
case $1 in
-h|--he|--hel|--help)
usage ;;
-q|--qu|--qui|--quie|--quiet)
quiet="true";
shift;;
-v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
verbose="-v";
shift;;
-c|--cl|--cle|--clea|--clean)
mode="clean";
shift;;
-*) echo "unknown option $1" ;
usage ;;
*) echo "invalid parameter $1" ;
usage ;;
esac
done
case $mode in
generate)
case $top_srcdir in
/* ) aclocal_dir=$top_srcdir
;;
*) aclocal_dir=`pwd`/$top_srcdir
;;
esac
confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print`
for i in $confs; do
dir=`dirname $i`;
configure=`basename $i`;
( test "$quiet" = "true" || echo "$dir";
cd $dir;
pat="s,\$(TOPdir),${aclocal_dir},g"
aclocal_args=`grep '^[ ]*ACLOCAL_AMFLAGS' Makefile.am | \
sed -e 's%.*ACLOCAL_AMFLAGS.*\=[ ]*%%g' -e $pat ` ;
test "$verbose" = "-v" && echo "aclocal $aclocal_args"
aclocal $aclocal_args;
test -n "`grep CONFIG_HEADER ${configure}`" && autoheader \
&& test "$verbose" = "-v" && echo "autoheader";
test -f Makefile.am && automake -a -c --foreign $verbose ;
test "$verbose" = "-v" && echo "autoconf";
autoconf;
test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \
&& echo timestamp > stamp-h.in
)
done
# HACK: Fixup the version in the generated configure script. This would be less of
# hack if it wasn't pspsdk-specific. I'm doing this because I don't want to look
# into how to do it the autoconf way.
version=`cat "$top_srcdir/VERSION"`
cat configure | sed "s/PSPSDK_VERSION/$version/g" > configure.out
cp configure.out configure
rm -f configure.out
;;
clean)
test "$quiet" = "true" || echo "removing automake generated Makefile.in files"
files=`find . -name 'Makefile.am' -print | sed -e 's%\.am%\.in%g'` ;
for i in $files; do if test -f $i; then
rm -f $i
test "$verbose" = "-v" && echo "$i"
fi; done
test "$quiet" = "true" || echo "removing configure files"
files=`find . -name 'configure' -print` ;
test "$verbose" = "-v" && test -n "$files" && echo "$files" ;
for i in $files; do if test -f $i; then
rm -f $i config.guess config.sub depcomp install-sh mdate-sh missing \
mkinstalldirs texinfo.tex
test "$verbose" = "-v" && echo "$i"
fi; done
test "$quiet" = "true" || echo "removing aclocal.m4 files"
files=`find . -name 'aclocal.m4' -print` ;
test "$verbose" = "-v" && test -n "$files" && echo "$files" ;
for i in $files; do if test -f $i; then
rm -f $i
test "$verbose" = "-v" && echo "$i"
fi; done
find . -name '*~' -print | xargs rm -f
find . -name '*.orig' -print | xargs rm -f
find . -name '*.rej' -print | xargs rm -f
find . -name 'config.status' -print | xargs rm -f
find . -name 'config.log' -print | xargs rm -f
find . -name 'config.cache' -print | xargs rm -f
find . -name 'Makefile' -print | xargs rm -f
find . -name '.deps' -print | xargs rm -rf
find . -name '.libs' -print | xargs rm -rf
find . -name 'stamp-h.in' | xargs rm -rf
;;
esac

81
config.h.in Normal file
View File

@@ -0,0 +1,81 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Toplevel directory where PSPSDK will be installed, relative to $prefix */
#undef PSPSDK_TOPDIR
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc

118
configure.ac Normal file
View File

@@ -0,0 +1,118 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT([pspsdk], [PSPSDK_VERSION], [])
AC_CONFIG_SRCDIR([tools/bin2c.c])
AC_CONFIG_HEADER([config.h])
AC_PSPSDK_VERSION
AC_PSPDEV_PATH
AM_INIT_AUTOMAKE([pspsdk], [PSPSDK_VERSION])
# Checks for programs.
AC_PSPDEV_TOOLCHAIN
AC_PROG_CC
# These will actually be overridden by the psp-specific counterparts. They are
# here mainly to shut automake up.
AC_PROG_CXX
AM_PROG_AS
AC_PROG_RANLIB
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h malloc.h stdlib.h string.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_CHECK_FUNCS([getcwd strchr])
# Doxygen.
DX_HTML_FEATURE(ON)
DX_CHM_FEATURE(OFF)
DX_CHI_FEATURE(OFF)
DX_MAN_FEATURE(OFF)
DX_RTF_FEATURE(OFF)
DX_XML_FEATURE(OFF)
DX_PDF_FEATURE(OFF)
DX_PS_FEATURE(OFF)
DX_INIT_DOXYGEN(pspsdk, doxygen.cfg, doc)
# Override the default prefix to point to where the pspdev tools should be installed.
# The binaries will end up in $prefix/bin, but pspsdk itself will end up in $prefix/$target/sdk.
# TODO: We should see if the user will ever want to override this.
prefix="$pspdev"
psp_targetdir="psp"
# Create the pspsdk installation paths.
pspsdk_topdir="$psp_targetdir/sdk"
pspsdk="$prefix/$pspsdk_topdir"
pspsdk_includedir="$pspsdk/include"
pspsdk_libdir="$pspsdk/lib"
PSPSDK="$pspsdk"
PSPSDK_INCLUDEDIR="$pspsdk_includedir"
PSPSDK_LIBDIR="$pspsdk_libdir"
AC_DEFINE_UNQUOTED(PSPSDK_TOPDIR, ["$pspsdk_topdir"],
[Toplevel directory where PSPSDK will be installed, relative to $prefix])
AC_SUBST(PSPSDK)
AC_SUBST(PSPSDK_INCLUDEDIR)
AC_SUBST(PSPSDK_LIBDIR)
# CFLAGS and CXXFLAGS used to build pspsdk libraries.
PSPSDK_CFLAGS="$CFLAGS -G0 -Wall"
PSPSDK_CXXFLAGS="$PSPSDK_CFLAGS -fno-exceptions -fno-rtti"
AC_SUBST(PSPSDK_CFLAGS)
AC_SUBST(PSPSDK_CXXFLAGS)
# Turn on all warnings (for host programs).
if test x$ac_compiler_gnu = xyes; then
CFLAGS="$CFLAGS -Wall"
fi
AC_CONFIG_FILES([Makefile
src/Makefile
src/atrac3/Makefile
src/audio/Makefile
src/base/Makefile
src/base/linkfile.prx
src/ctrl/Makefile
src/debug/Makefile
src/display/Makefile
src/fpu/Makefile
src/ge/Makefile
src/gu/Makefile
src/gum/Makefile
src/hprm/Makefile
src/kernel/Makefile
src/libc/Makefile
src/mp3/Makefile
src/mpeg/Makefile
src/nand/Makefile
src/net/Makefile
src/openpsid/Makefile
src/power/Makefile
src/prof/Makefile
src/registry/Makefile
src/rtc/Makefile
src/sircs/Makefile
src/sdk/Makefile
src/startup/Makefile
src/umd/Makefile
src/usb/Makefile
src/usbstor/Makefile
src/user/Makefile
src/utility/Makefile
src/vfpu/Makefile
src/video/Makefile
src/vsh/Makefile
src/wlan/Makefile
src/samples/Makefile
tools/Makefile])
AC_OUTPUT

1226
doxygen.cfg Normal file

File diff suppressed because it is too large Load Diff

36
src/Makefile.am Normal file
View File

@@ -0,0 +1,36 @@
SUBDIRS = \
atrac3 \
audio \
base \
ctrl \
debug \
display \
fpu \
ge \
gu \
gum \
hprm \
kernel \
libc \
mp3 \
mpeg \
nand \
net \
openpsid \
power \
prof \
registry \
rtc \
sircs \
sdk \
startup \
umd \
usb \
usbstor \
user \
utility \
vfpu \
video \
vsh \
wlan \
samples

23
src/atrac3/Makefile.am Normal file
View File

@@ -0,0 +1,23 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
ATRAC3_OBJS = sceAtrac3plus_0000.o sceAtrac3plus_0001.o sceAtrac3plus_0002.o sceAtrac3plus_0003.o sceAtrac3plus_0004.o sceAtrac3plus_0005.o sceAtrac3plus_0006.o sceAtrac3plus_0007.o sceAtrac3plus_0008.o sceAtrac3plus_0009.o sceAtrac3plus_0010.o sceAtrac3plus_0011.o sceAtrac3plus_0012.o sceAtrac3plus_0013.o sceAtrac3plus_0014.o sceAtrac3plus_0015.o sceAtrac3plus_0016.o sceAtrac3plus_0017.o sceAtrac3plus_0018.o sceAtrac3plus_0019.o sceAtrac3plus_0020.o sceAtrac3plus_0021.o sceAtrac3plus_0022.o sceAtrac3plus_0023.o sceAtrac3plus_0024.o sceAtrac3plus_0025.o
libpspatrac3includedir = @PSPSDK_INCLUDEDIR@
libpspatrac3include_HEADERS = pspatrac3.h
lib_LIBRARIES = libpspatrac3.a
libpspatrac3_a_SOURCES = sceAtrac3plus.S
libpspatrac3_a_LIBADD = $(ATRAC3_OBJS)
$(ATRAC3_OBJS): sceAtrac3plus.S
$(COMPILE) -DF_$* $< -c -o $@

139
src/atrac3/pspatrac3.h Normal file
View File

@@ -0,0 +1,139 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspatrac3.h - Prototypes for the sceAtrac3plus library
*
* Copyright (c) 2006 moonlight
*
* $Id: pspatrac3.h 2433 2008-10-15 10:00:27Z iwn $
*/
#ifndef __LIBATRAC3_H__
#define __LIBATRAC3_H__
#include <psptypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Creates a new Atrac ID from the specified data
*
* @param buf - the buffer holding the atrac3 data, including the RIFF/WAVE header.
* @param bufsize - the size of the buffer pointed by buf
*
* @return the new atrac ID, or < 0 on error
*/
int sceAtracSetDataAndGetID(void *buf, SceSize bufsize);
/**
* Decode a frame of data.
*
* @param atracID - the atrac ID
* @param outSamples - pointer to a buffer that receives the decoded data of the current frame
* @param outN - pointer to a integer that receives the number of audio samples of the decoded frame
* @param outEnd - pointer to a integer that receives a boolean value indicating if the decoded frame is the last one
* @param outRemainFrame - pointer to a integer that receives either -1 if all at3 data is already on memory,
* or the remaining (not decoded yet) frames at memory if not all at3 data is on memory
*
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracDecodeData(int atracID, u16 *outSamples, int *outN, int *outEnd, int *outRemainFrame);
/**
* Gets the remaining (not decoded) number of frames
*
* @param atracID - the atrac ID
* @param outRemainFrame - pointer to a integer that receives either -1 if all at3 data is already on memory,
* or the remaining (not decoded yet) frames at memory if not all at3 data is on memory
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracGetRemainFrame(int atracID, int *outRemainFrame);
/**
*
* @param atracID - the atrac ID
* @param writePointer - Pointer to where to read the atrac data
* @param availableBytes - Number of bytes available at the writePointer location
* @param readOffset - Offset where to seek into the atrac file before reading
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracGetStreamDataInfo(int atracID, u8** writePointer, u32* availableBytes, u32* readOffset);
/**
*
* @param atracID - the atrac ID
* @param bytesToAdd - Number of bytes read into location given by sceAtracGetStreamDataInfo().
*
* @return < 0 on error, otherwise 0
*/
int sceAtracAddStreamData(int atracID, unsigned int bytesToAdd);
/**
* Gets the bitrate.
*
* @param atracID - the atracID
* @param outBitrate - pointer to a integer that receives the bitrate in kbps
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracGetBitrate(int atracID, int *outBitrate);
/**
* Sets the number of loops for this atrac ID
*
* @param atracID - the atracID
* @param nloops - the number of loops to set
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracSetLoopNum(int atracID, int nloops);
/**
* It releases an atrac ID
*
* @param atracID - the atrac ID to release
*
* @return < 0 on error
*
*/
int sceAtracReleaseAtracID(int atracID);
/**
* Gets the number of samples of the next frame to be decoded.
*
* @param atracID - the atrac ID
* @param outN - pointer to receives the number of samples of the next frame.
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracGetNextSample(int atracID, int *outN);
/**
* Gets the maximum number of samples of the atrac3 stream.
*
* @param atracID - the atrac ID
* @param outMax - pointer to a integer that receives the maximum number of samples.
*
* @return < 0 on error, otherwise 0
*
*/
int sceAtracGetMaxSample(int atracID, int *outMax);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,82 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceAtrac3plus_0000
IMPORT_START "sceAtrac3plus",0x00090000
#endif
#ifdef F_sceAtrac3plus_0001
IMPORT_FUNC "sceAtrac3plus",0xD1F59FDB,sceAtracStartEntry
#endif
#ifdef F_sceAtrac3plus_0002
IMPORT_FUNC "sceAtrac3plus",0xD5C28CC0,sceAtracEndEntry
#endif
#ifdef F_sceAtrac3plus_0003
IMPORT_FUNC "sceAtrac3plus",0x780F88D1,sceAtracGetAtracID
#endif
#ifdef F_sceAtrac3plus_0004
IMPORT_FUNC "sceAtrac3plus",0x61EB33F5,sceAtracReleaseAtracID
#endif
#ifdef F_sceAtrac3plus_0005
IMPORT_FUNC "sceAtrac3plus",0x0E2A73AB,sceAtracSetData
#endif
#ifdef F_sceAtrac3plus_0006
IMPORT_FUNC "sceAtrac3plus",0x3F6E26B5,sceAtracSetHalfwayBuffer
#endif
#ifdef F_sceAtrac3plus_0007
IMPORT_FUNC "sceAtrac3plus",0x7A20E7AF,sceAtracSetDataAndGetID
#endif
#ifdef F_sceAtrac3plus_0008
IMPORT_FUNC "sceAtrac3plus",0x0FAE370E,sceAtracSetHalfwayBufferAndGetID
#endif
#ifdef F_sceAtrac3plus_0009
IMPORT_FUNC "sceAtrac3plus",0x6A8C3CD5,sceAtracDecodeData
#endif
#ifdef F_sceAtrac3plus_0010
IMPORT_FUNC "sceAtrac3plus",0x9AE849A7,sceAtracGetRemainFrame
#endif
#ifdef F_sceAtrac3plus_0011
IMPORT_FUNC "sceAtrac3plus",0x5D268707,sceAtracGetStreamDataInfo
#endif
#ifdef F_sceAtrac3plus_0012
IMPORT_FUNC "sceAtrac3plus",0x7DB31251,sceAtracAddStreamData
#endif
#ifdef F_sceAtrac3plus_0013
IMPORT_FUNC "sceAtrac3plus",0x83E85EA0,sceAtracGetSecondBufferInfo
#endif
#ifdef F_sceAtrac3plus_0014
IMPORT_FUNC "sceAtrac3plus",0x83BF7AFD,sceAtracSetSecondBuffer
#endif
#ifdef F_sceAtrac3plus_0015
IMPORT_FUNC "sceAtrac3plus",0xE23E3A35,sceAtracGetNextDecodePosition
#endif
#ifdef F_sceAtrac3plus_0016
IMPORT_FUNC "sceAtrac3plus",0xA2BBA8BE,sceAtracGetSoundSample
#endif
#ifdef F_sceAtrac3plus_0017
IMPORT_FUNC "sceAtrac3plus",0x31668BAA,sceAtracGetChannel
#endif
#ifdef F_sceAtrac3plus_0018
IMPORT_FUNC "sceAtrac3plus",0xD6A5F2F7,sceAtracGetMaxSample
#endif
#ifdef F_sceAtrac3plus_0019
IMPORT_FUNC "sceAtrac3plus",0x36FAABFB,sceAtracGetNextSample
#endif
#ifdef F_sceAtrac3plus_0020
IMPORT_FUNC "sceAtrac3plus",0xA554A158,sceAtracGetBitrate
#endif
#ifdef F_sceAtrac3plus_0021
IMPORT_FUNC "sceAtrac3plus",0xFAA4F89B,sceAtracGetLoopStatus
#endif
#ifdef F_sceAtrac3plus_0022
IMPORT_FUNC "sceAtrac3plus",0x868120B5,sceAtracSetLoopNum
#endif
#ifdef F_sceAtrac3plus_0023
IMPORT_FUNC "sceAtrac3plus",0xCA3CA3D2,sceAtracGetBufferInfoForReseting
#endif
#ifdef F_sceAtrac3plus_0024
IMPORT_FUNC "sceAtrac3plus",0x644E5607,sceAtracResetPlayPosition
#endif
#ifdef F_sceAtrac3plus_0025
IMPORT_FUNC "sceAtrac3plus",0xE88F759B,sceAtracGetInternalErrorInfo
#endif

51
src/audio/Makefile.am Normal file
View File

@@ -0,0 +1,51 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/user -I$(top_srcdir)/src/debug
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) $(INCLUDES)
AUDIO_OBJS = sceAudio_0000.o sceAudio_0001.o sceAudio_0002.o sceAudio_0003.o sceAudio_0004.o sceAudio_0005.o sceAudio_0006.o sceAudio_0007.o sceAudio_0008.o sceAudio_0009.o sceAudio_0010.o sceAudio_0011.o sceAudio_0012.o sceAudio_0013.o sceAudio_0014.o sceAudio_0015.o sceAudio_0016.o sceAudio_0017.o sceAudio_0018.o sceAudio_0019.o sceAudio_0020.o sceAudio_0021.o sceAudio_0022.o sceAudio_0023.o sceAudio_0024.o sceAudio_0025.o sceAudio_0026.o sceAudio_0027.o
AUDIO_DRIVER_OBJS = sceAudio_driver_0000.o sceAudio_driver_0001.o sceAudio_driver_0002.o sceAudio_driver_0003.o sceAudio_driver_0004.o sceAudio_driver_0005.o sceAudio_driver_0006.o sceAudio_driver_0007.o sceAudio_driver_0008.o sceAudio_driver_0009.o sceAudio_driver_0010.o sceAudio_driver_0011.o sceAudio_driver_0012.o sceAudio_driver_0013.o sceAudio_driver_0014.o sceAudio_driver_0015.o sceAudio_driver_0016.o sceAudio_driver_0017.o sceAudio_driver_0018.o sceAudio_driver_0019.o sceAudio_driver_0020.o sceAudio_driver_0021.o sceAudio_driver_0022.o sceAudio_driver_0023.o sceAudio_driver_0024.o sceAudio_driver_0025.o sceAudio_driver_0026.o sceAudio_driver_0027.o
CODEC_OBJS = sceAudiocodec_0000.o sceAudiocodec_0001.o sceAudiocodec_0002.o sceAudiocodec_0003.o sceAudiocodec_0004.o sceAudiocodec_0005.o sceAudiocodec_0006.o sceAudiocodec_0007.o sceAudiocodec_0008.o
libpspaudioincludedir = @PSPSDK_INCLUDEDIR@
libpspaudioinclude_HEADERS = pspaudio.h
libpspaudio_driverincludedir = @PSPSDK_INCLUDEDIR@
libpspaudio_driverinclude_HEADERS = pspaudio_kernel.h
libpspaudiolibincludedir = @PSPSDK_INCLUDEDIR@
libpspaudiolibinclude_HEADERS = pspaudiolib.h
libpspaudiocodecincludedir = @PSPSDK_INCLUDEDIR@
libpspaudiocodecinclude_HEADERS = pspaudiocodec.h
lib_LIBRARIES = libpspaudio.a libpspaudio_driver.a libpspaudiolib.a libpspaudiocodec.a
libpspaudio_a_SOURCES = sceAudio.S
libpspaudio_a_LIBADD = $(AUDIO_OBJS)
libpspaudio_driver_a_SOURCES = sceAudio_driver.S
libpspaudio_driver_a_LIBADD = $(AUDIO_DRIVER_OBJS)
libpspaudiolib_a_SOURCES = pspaudiolib.c
libpspaudiocodec_a_SOURCES = sceAudiocodec.S
libpspaudiocodec_a_LIBADD = $(CODEC_OBJS)
$(AUDIO_OBJS): sceAudio.S
$(COMPILE) -DF_$* $< -c -o $@
$(AUDIO_DRIVER_OBJS): sceAudio_driver.S
$(COMPILE) -DF_$* $< -c -o $@
$(CODEC_OBJS): sceAudiocodec.S
$(COMPILE) -DF_$* $< -c -o $@

354
src/audio/pspaudio.h Normal file
View File

@@ -0,0 +1,354 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspaudio.h - Prototypes for the sceAudio library.
*
* Copyright (c) 2005 Adresd
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2007 cooleyes
* Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
* Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
*
* $Id: pspaudio.h 2433 2008-10-15 10:00:27Z iwn $
*/
#ifndef PSPAUDIO_H
#define PSPAUDIO_H
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup Audio User Audio Library */
/** @addtogroup Audio */
/*@{*/
/** The maximum output volume. */
#define PSP_AUDIO_VOLUME_MAX 0x8000
/** The maximum number of hardware channels. */
#define PSP_AUDIO_CHANNEL_MAX 8
/** Used to request the next available hardware channel. */
#define PSP_AUDIO_NEXT_CHANNEL (-1)
enum PspAudioFormats
{
/** Channel is set to stereo output. */
PSP_AUDIO_FORMAT_STEREO = 0,
/** Channel is set to mono output. */
PSP_AUDIO_FORMAT_MONO = 0x10
};
typedef struct
{
/** Unknown. Pass 0 */
int unknown1;
int gain;
/** Unknown. Pass 0 */
int unknown2;
/** Unknown. Pass 0 */
int unknown3;
/** Unknown. Pass 0 */
int unknown4;
/** Unknown. Pass 0 */
int unknown5;
} pspAudioInputParams;
/** The minimum number of samples that can be allocated to a channel. */
#define PSP_AUDIO_SAMPLE_MIN 64
/** The maximum number of samples that can be allocated to a channel. */
#define PSP_AUDIO_SAMPLE_MAX 65472
/** Make the given sample count a multiple of 64. */
#define PSP_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63)
/**
* Allocate and initialize a hardware output channel.
*
* @param channel - Use a value between 0 - 7 to reserve a specific channel.
* Pass PSP_AUDIO_NEXT_CHANNEL to get the first available channel.
* @param samplecount - The number of samples that can be output on the channel per
* output call. It must be a value between ::PSP_AUDIO_SAMPLE_MIN
* and ::PSP_AUDIO_SAMPLE_MAX, and it must be aligned to 64 bytes
* (use the ::PSP_AUDIO_SAMPLE_ALIGN macro to align it).
* @param format - The output format to use for the channel. One of ::PspAudioFormats.
*
* @return The channel number on success, an error code if less than 0.
*/
int sceAudioChReserve(int channel, int samplecount, int format);
/**
* Release a hardware output channel.
*
* @param channel - The channel to release.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioChRelease(int channel);
/**
* Output audio of the specified channel
*
* @param channel - The channel number.
*
* @param vol - The volume.
*
* @param buf - Pointer to the PCM data to output.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutput(int channel, int vol, void *buf);
/**
* Output audio of the specified channel (blocking)
*
* @param channel - The channel number.
*
* @param vol - The volume.
*
* @param buf - Pointer to the PCM data to output.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutputBlocking(int channel, int vol, void *buf);
/**
* Output panned audio of the specified channel
*
* @param channel - The channel number.
*
* @param leftvol - The left volume.
*
* @param rightvol - The right volume.
*
* @param buf - Pointer to the PCM data to output.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutputPanned(int channel, int leftvol, int rightvol, void *buf);
/**
* Output panned audio of the specified channel (blocking)
*
* @param channel - The channel number.
*
* @param leftvol - The left volume.
*
* @param rightvol - The right volume.
*
* @param buf - Pointer to the PCM data to output.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutputPannedBlocking(int channel, int leftvol, int rightvol, void *buf);
/**
* Get count of unplayed samples remaining
*
* @param channel - The channel number.
*
* @return Number of samples to be played, an error if less than 0.
*/
int sceAudioGetChannelRestLen(int channel);
/**
* Get count of unplayed samples remaining
*
* @param channel - The channel number.
*
* @return Number of samples to be played, an error if less than 0.
*/
int sceAudioGetChannelRestLength(int channel);
/**
* Change the output sample count, after it's already been reserved
*
* @param channel - The channel number.
* @param samplecount - The number of samples to output in one output call.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioSetChannelDataLen(int channel, int samplecount);
/**
* Change the format of a channel
*
* @param channel - The channel number.
*
* @param format - One of ::PspAudioFormats
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioChangeChannelConfig(int channel, int format);
/**
* Change the volume of a channel
*
* @param channel - The channel number.
*
* @param leftvol - The left volume.
*
* @param rightvol - The right volume.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioChangeChannelVolume(int channel, int leftvol, int rightvol);
//sceAudioOneshotOutput ???
/**
* Reserve the audio output and set the output sample count
*
* @param samplecount - The number of samples to output in one output call (min 17, max 4111).
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutput2Reserve(int samplecount);
/**
* Release the audio output
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutput2Release(void);
/**
* Change the output sample count, after it's already been reserved
*
* @param samplecount - The number of samples to output in one output call (min 17, max 4111).
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutput2ChangeLength(int samplecount);
/**
* Output audio (blocking)
*
* @param vol - The volume.
*
* @param buf - Pointer to the PCM data.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioOutput2OutputBlocking(int vol, void *buf);
/**
* Get count of unplayed samples remaining
*
* @return Number of samples to be played, an error if less than 0.
*/
int sceAudioOutput2GetRestSample(void);
/**
* Reserve the audio output
*
* @param samplecount - The number of samples to output in one output call (min 17, max 4111).
*
* @param freq - The frequency. One of 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11050, 8000.
*
* @param channels - Number of channels. Pass 2 (stereo).
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioSRCChReserve(int samplecount, int freq, int channels);
/**
* Release the audio output
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioSRCChRelease(void);
/**
* Output audio
*
* @param vol - The volume.
*
* @param buf - Pointer to the PCM data to output.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioSRCOutputBlocking(int vol, void *buf);
/**
* Init audio input
*
* @param unknown1 - Unknown. Pass 0.
*
* @param gain - Gain.
*
* @param unknown2 - Unknown. Pass 0.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioInputInit(int unknown1, int gain, int unknown2);
/**
* Init audio input (with extra arguments)
*
* @param params - A pointer to a ::pspAudioInputParams struct.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioInputInitEx(pspAudioInputParams *params);
/**
* Perform audio input (blocking)
*
* @param samplecount - Number of samples.
*
* @param freq - Either 44100, 22050 or 11025.
*
* @param buf - Pointer to where the audio data will be stored.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioInputBlocking(int samplecount, int freq, void *buf);
/**
* Perform audio input
*
* @param samplecount - Number of samples.
*
* @param freq - Either 44100, 22050 or 11025.
*
* @param buf - Pointer to where the audio data will be stored.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioInput(int samplecount, int freq, void *buf);
/**
* Get the number of samples that were acquired
*
* @return Number of samples acquired, an error if less than 0.
*/
int sceAudioGetInputLength(void);
/**
* Wait for non-blocking audio input to complete
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioWaitInputEnd(void);
/**
* Poll for non-blocking audio input status
*
* @return 0 if input has completed, 1 if not completed or an error if less than 0.
*/
int sceAudioPollInputEnd(void);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif /* PSPAUDIO_H */

49
src/audio/pspaudio_kernel.h Executable file
View File

@@ -0,0 +1,49 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspaudio.h - Prototypes for the sceAudio library.
*
* Copyright (c) 2005 Adresd
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2007 cooleyes
* Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
*
* $Id: pspaudio_kernel.h 2433 2008-10-15 10:00:27Z iwn $
*/
#ifndef PSPAUDIO_KERNEL_H
#define PSPAUDIO_KERNEL_H
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup Audio User Audio Library */
/** @addtogroup Audio */
/*@{*/
enum PspAudioFrequencies {
/** Sampling frequency set to 44100Hz. */
PSP_AUDIO_FREQ_44K = 44100,
/** Sampling frequency set to 48000Hz. */
PSP_AUDIO_FREQ_48K = 48000
};
/**
* Set audio sampling frequency
*
* @param frequency - Sampling frequency to set audio output to - either 44100 or 48000.
*
* @return 0 on success, an error if less than 0.
*/
int sceAudioSetFrequency(int frequency);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif /* PSPAUDIO_KERNEL_H */

31
src/audio/pspaudiocodec.h Normal file
View File

@@ -0,0 +1,31 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspaudiocodec.h - Prototypes for the sceAudiocodec library.
*
* Copyright (c) 2006 hitchhikr
*
* $Id: pspaudiocodec.h 2430 2008-08-28 12:04:04Z Raphael $
*/
#ifdef __cplusplus
extern "C" {
#endif
#define PSP_CODEC_AT3PLUS (0x00001000)
#define PSP_CODEC_AT3 (0x00001001)
#define PSP_CODEC_MP3 (0x00001002)
#define PSP_CODEC_AAC (0x00001003)
int sceAudiocodecCheckNeedMem(unsigned long *Buffer, int Type);
int sceAudiocodecInit(unsigned long *Buffer, int Type);
int sceAudiocodecDecode(unsigned long *Buffer, int Type);
int sceAudiocodecGetEDRAM(unsigned long *Buffer, int Type);
int sceAudiocodecReleaseEDRAM(unsigned long *Buffer);
#ifdef __cplusplus
}
#endif

177
src/audio/pspaudiolib.c Normal file
View File

@@ -0,0 +1,177 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspaudiolib.c - Audio library build on top of sceAudio, but to provide
* multiple thread usage and callbacks.
*
* Copyright (c) 2005 Adresd
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
*
* $Id: pspaudiolib.c 1145 2005-10-12 15:32:44Z mrbrown $
*/
#include <stdlib.h>
#include <string.h>
#include <pspthreadman.h>
#include <pspaudio.h>
#include "pspaudiolib.h"
static int audio_ready=0;
static short audio_sndbuf[PSP_NUM_AUDIO_CHANNELS][2][PSP_NUM_AUDIO_SAMPLES][2];
static psp_audio_channelinfo AudioStatus[PSP_NUM_AUDIO_CHANNELS];
static volatile int audio_terminate=0;
void pspAudioSetVolume(int channel, int left, int right)
{
AudioStatus[channel].volumeright = right;
AudioStatus[channel].volumeleft = left;
}
void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn)
{
pspAudioCallback_t callback;
callback=AudioStatus[channel].callback;
}
void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata)
{
volatile psp_audio_channelinfo *pci = &AudioStatus[channel];
pci->callback=0;
pci->pdata=pdata;
pci->callback=callback;
}
int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf)
{
if (!audio_ready) return -1;
if (channel>=PSP_NUM_AUDIO_CHANNELS) return -1;
if (vol1>PSP_VOLUME_MAX) vol1=PSP_VOLUME_MAX;
if (vol2>PSP_VOLUME_MAX) vol2=PSP_VOLUME_MAX;
return sceAudioOutputPannedBlocking(AudioStatus[channel].handle,vol1,vol2,buf);
}
static int AudioChannelThread(int args, void *argp)
{
volatile int bufidx=0;
int channel=*(int *)argp;
while (audio_terminate==0) {
void *bufptr=&audio_sndbuf[channel][bufidx];
pspAudioCallback_t callback;
callback=AudioStatus[channel].callback;
if (callback) {
callback(bufptr, PSP_NUM_AUDIO_SAMPLES, AudioStatus[channel].pdata);
} else {
unsigned int *ptr=bufptr;
int i;
for (i=0; i<PSP_NUM_AUDIO_SAMPLES; ++i) *(ptr++)=0;
}
pspAudioOutBlocking(channel,AudioStatus[channel].volumeleft,AudioStatus[channel].volumeright,bufptr);
bufidx=(bufidx?0:1);
}
sceKernelExitThread(0);
return 0;
}
/******************************************************************************/
int pspAudioInit()
{
int i,ret;
int failed=0;
char str[32];
audio_terminate=0;
audio_ready=0;
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
AudioStatus[i].handle = -1;
AudioStatus[i].threadhandle = -1;
AudioStatus[i].volumeright = PSP_VOLUME_MAX;
AudioStatus[i].volumeleft = PSP_VOLUME_MAX;
AudioStatus[i].callback = 0;
AudioStatus[i].pdata = 0;
}
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
if ((AudioStatus[i].handle = sceAudioChReserve(-1,PSP_NUM_AUDIO_SAMPLES,0))<0)
failed=1;
}
if (failed) {
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
if (AudioStatus[i].handle != -1)
sceAudioChRelease(AudioStatus[i].handle);
AudioStatus[i].handle = -1;
}
return -1;
}
audio_ready = 1;
strcpy(str,"audiot0");
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
str[6]='0'+i;
AudioStatus[i].threadhandle = sceKernelCreateThread(str,(void*)&AudioChannelThread,0x12,0x10000,0,NULL);
if (AudioStatus[i].threadhandle < 0) {
AudioStatus[i].threadhandle = -1;
failed=1;
break;
}
ret=sceKernelStartThread(AudioStatus[i].threadhandle,sizeof(i),&i);
if (ret!=0) {
failed=1;
break;
}
}
if (failed) {
audio_terminate=1;
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
if (AudioStatus[i].threadhandle != -1) {
//sceKernelWaitThreadEnd(AudioStatus[i].threadhandle,NULL);
sceKernelDeleteThread(AudioStatus[i].threadhandle);
}
AudioStatus[i].threadhandle = -1;
}
audio_ready=0;
return -1;
}
return 0;
}
void pspAudioEndPre()
{
audio_ready=0;
audio_terminate=1;
}
void pspAudioEnd()
{
int i;
audio_ready=0;
audio_terminate=1;
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
if (AudioStatus[i].threadhandle != -1) {
//sceKernelWaitThreadEnd(AudioStatus[i].threadhandle,NULL);
sceKernelDeleteThread(AudioStatus[i].threadhandle);
}
AudioStatus[i].threadhandle = -1;
}
for (i=0; i<PSP_NUM_AUDIO_CHANNELS; i++) {
if (AudioStatus[i].handle != -1) {
sceAudioChRelease(AudioStatus[i].handle);
AudioStatus[i].handle = -1;
}
}
}

53
src/audio/pspaudiolib.h Normal file
View File

@@ -0,0 +1,53 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspaudiolib.h - Audio library build on top of sceAudio, but to provide
* multiple thread usage and callbacks.
*
* Copyright (c) 2005 Adresd
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
*
* $Id: pspaudiolib.h 1874 2006-04-18 13:20:58Z tyranid $
*/
#ifndef __AUDIOLIB_H__
#define __AUDIOLIB_H__
#ifdef __cplusplus
extern "C" {
#endif
#define PSP_NUM_AUDIO_CHANNELS 4
/** This is the number of frames you can update per callback, a frame being
* 1 sample for mono, 2 samples for stereo etc. */
#define PSP_NUM_AUDIO_SAMPLES 1024
#define PSP_VOLUME_MAX 0x8000
typedef void (* pspAudioCallback_t)(void *buf, unsigned int reqn, void *pdata);
typedef struct {
int threadhandle;
int handle;
int volumeleft;
int volumeright;
pspAudioCallback_t callback;
void *pdata;
} psp_audio_channelinfo;
typedef int (* pspAudioThreadfunc_t)(int args, void *argp);
int pspAudioInit();
void pspAudioEndPre();
void pspAudioEnd();
void pspAudioSetVolume(int channel, int left, int right);
void pspAudioChannelThreadCallback(int channel, void *buf, unsigned int reqn);
void pspAudioSetChannelCallback(int channel, pspAudioCallback_t callback, void *pdata);
int pspAudioOutBlocking(unsigned int channel, unsigned int vol1, unsigned int vol2, void *buf);
#ifdef __cplusplus
}
#endif
#endif

89
src/audio/sceAudio.S Normal file
View File

@@ -0,0 +1,89 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceAudio_0000
IMPORT_START "sceAudio",0x40010000
#endif
#ifdef F_sceAudio_0001
IMPORT_FUNC "sceAudio",0x8C1009B2,sceAudioOutput
#endif
#ifdef F_sceAudio_0002
IMPORT_FUNC "sceAudio",0x136CAF51,sceAudioOutputBlocking
#endif
#ifdef F_sceAudio_0003
IMPORT_FUNC "sceAudio",0xE2D56B2D,sceAudioOutputPanned
#endif
#ifdef F_sceAudio_0004
IMPORT_FUNC "sceAudio",0x13F592BC,sceAudioOutputPannedBlocking
#endif
#ifdef F_sceAudio_0005
IMPORT_FUNC "sceAudio",0x5EC81C55,sceAudioChReserve
#endif
#ifdef F_sceAudio_0006
IMPORT_FUNC "sceAudio",0x41EFADE7,sceAudioOneshotOutput
#endif
#ifdef F_sceAudio_0007
IMPORT_FUNC "sceAudio",0x6FC46853,sceAudioChRelease
#endif
#ifdef F_sceAudio_0008
IMPORT_FUNC "sceAudio",0xE9D97901,sceAudioGetChannelRestLen
#endif
#ifdef F_sceAudio_0009
IMPORT_FUNC "sceAudio",0xCB2E439E,sceAudioSetChannelDataLen
#endif
#ifdef F_sceAudio_0010
IMPORT_FUNC "sceAudio",0x95FD0C2D,sceAudioChangeChannelConfig
#endif
#ifdef F_sceAudio_0011
IMPORT_FUNC "sceAudio",0xB7E1D8E7,sceAudioChangeChannelVolume
#endif
#ifdef F_sceAudio_0012
IMPORT_FUNC "sceAudio",0x38553111,sceAudioSRCChReserve
#endif
#ifdef F_sceAudio_0013
IMPORT_FUNC "sceAudio",0x5C37C0AE,sceAudioSRCChRelease
#endif
#ifdef F_sceAudio_0014
IMPORT_FUNC "sceAudio",0xE0727056,sceAudioSRCOutputBlocking
#endif
#ifdef F_sceAudio_0015
IMPORT_FUNC "sceAudio",0x086E5895,sceAudioInputBlocking
#endif
#ifdef F_sceAudio_0016
IMPORT_FUNC "sceAudio",0x6D4BEC68,sceAudioInput
#endif
#ifdef F_sceAudio_0017
IMPORT_FUNC "sceAudio",0xA708C6A6,sceAudioGetInputLength
#endif
#ifdef F_sceAudio_0018
IMPORT_FUNC "sceAudio",0x87B2E651,sceAudioWaitInputEnd
#endif
#ifdef F_sceAudio_0019
IMPORT_FUNC "sceAudio",0x7DE61688,sceAudioInputInit
#endif
#ifdef F_sceAudio_0020
IMPORT_FUNC "sceAudio",0xA633048E,sceAudioPollInputEnd
#endif
#ifdef F_sceAudio_0021
IMPORT_FUNC "sceAudio",0xB011922F,sceAudioGetChannelRestLength
#endif
#ifdef F_sceAudio_0022
IMPORT_FUNC "sceAudio",0xE926D3FB,sceAudioInputInitEx
#endif
#ifdef F_sceAudio_0023
IMPORT_FUNC "sceAudio",0x01562BA3,sceAudioOutput2Reserve
#endif
#ifdef F_sceAudio_0024
IMPORT_FUNC "sceAudio",0x2D53F36E,sceAudioOutput2OutputBlocking
#endif
#ifdef F_sceAudio_0025
IMPORT_FUNC "sceAudio",0x43196845,sceAudioOutput2Release
#endif
#ifdef F_sceAudio_0026
IMPORT_FUNC "sceAudio",0x63F2889C,sceAudioOutput2ChangeLength
#endif
#ifdef F_sceAudio_0027
IMPORT_FUNC "sceAudio",0x647CEF33,sceAudioOutput2GetRestSample
#endif

116
src/audio/sceAudio_driver.S Executable file
View File

@@ -0,0 +1,116 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceAudio_driver_0000
IMPORT_START "sceAudio_driver",0x00010000
#endif
#ifdef F_sceAudio_driver_0001
IMPORT_FUNC "sceAudio_driver",0x80F1F7E0,sceAudioInit
#endif
#ifdef F_sceAudio_driver_0002
IMPORT_FUNC "sceAudio_driver",0x210567F7,sceAudioEnd
#endif
#ifdef F_sceAudio_driver_0003
IMPORT_FUNC "sceAudio_driver",0xA2BEAA6C,sceAudioSetFrequency
#endif
#ifdef F_sceAudio_driver_0004
IMPORT_FUNC "sceAudio_driver",0xB61595C0,sceAudioLoopbackTest
#endif
#ifdef F_sceAudio_driver_0005
IMPORT_FUNC "sceAudio_driver",0x927AC32B,sceAudioSetVolumeOffset
#endif
#ifdef F_sceAudio_driver_0006
IMPORT_FUNC "sceAudio_driver",0x8C1009B2,sceAudioOutput
#endif
#ifdef F_sceAudio_driver_0007
IMPORT_FUNC "sceAudio_driver",0x136CAF51,sceAudioOutputBlocking
#endif
#ifdef F_sceAudio_driver_0008
IMPORT_FUNC "sceAudio_driver",0xE2D56B2D,sceAudioOutputPanned
#endif
#ifdef F_sceAudio_driver_0009
IMPORT_FUNC "sceAudio_driver",0x13F592BC,sceAudioOutputPannedBlocking
#endif
#ifdef F_sceAudio_driver_0010
IMPORT_FUNC "sceAudio_driver",0x5EC81C55,sceAudioChReserve
#endif
#ifdef F_sceAudio_driver_0011
IMPORT_FUNC "sceAudio_driver",0x41EFADE7,sceAudioOneshotOutput
#endif
#ifdef F_sceAudio_driver_0012
IMPORT_FUNC "sceAudio_driver",0x6FC46853,sceAudioChRelease
#endif
#ifdef F_sceAudio_driver_0013
IMPORT_FUNC "sceAudio_driver",0xB011922F,sceAudio_driver_B011922F
#endif
#ifdef F_sceAudio_driver_0014
IMPORT_FUNC "sceAudio_driver",0xCB2E439E,sceAudioSetChannelDataLen
#endif
#ifdef F_sceAudio_driver_0015
IMPORT_FUNC "sceAudio_driver",0x95FD0C2D,sceAudioChangeChannelConfig
#endif
#ifdef F_sceAudio_driver_0016
IMPORT_FUNC "sceAudio_driver",0xB7E1D8E7,sceAudioChangeChannelVolume
#endif
#ifdef F_sceAudio_driver_0017
IMPORT_FUNC "sceAudio_driver",0x38553111,sceAudio_driver_38553111
#endif
#ifdef F_sceAudio_driver_0018
IMPORT_FUNC "sceAudio_driver",0x5C37C0AE,sceAudio_driver_5C37C0AE
#endif
#ifdef F_sceAudio_driver_0019
IMPORT_FUNC "sceAudio_driver",0xE0727056,sceAudio_driver_E0727056
#endif
#ifdef F_sceAudio_driver_0020
IMPORT_FUNC "sceAudio_driver",0x086E5895,sceAudioInputBlocking
#endif
#ifdef F_sceAudio_driver_0021
IMPORT_FUNC "sceAudio_driver",0x6D4BEC68,sceAudioInput
#endif
#ifdef F_sceAudio_driver_0022
IMPORT_FUNC "sceAudio_driver",0xA708C6A6,sceAudioGetInputLength
#endif
#ifdef F_sceAudio_driver_0023
IMPORT_FUNC "sceAudio_driver",0x87B2E651,sceAudioWaitInputEnd
#endif
#ifdef F_sceAudio_driver_0024
IMPORT_FUNC "sceAudio_driver",0x7DE61688,sceAudioInputInit
#endif
#ifdef F_sceAudio_driver_0025
IMPORT_FUNC "sceAudio_driver",0xE926D3FB,sceAudioInputInitEx
#endif
#ifdef F_sceAudio_driver_0026
IMPORT_FUNC "sceAudio_driver",0xA633048E,sceAudioPollInputEnd
#endif
#ifdef F_sceAudio_driver_0027
IMPORT_FUNC "sceAudio_driver",0xE9D97901,sceAudioGetChannelRestLen
#endif

31
src/audio/sceAudiocodec.S Normal file
View File

@@ -0,0 +1,31 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceAudiocodec_0000
IMPORT_START "sceAudiocodec",0x40090000
#endif
#ifdef F_sceAudiocodec_0001
IMPORT_FUNC "sceAudiocodec",0x9D3F790C,sceAudiocodecCheckNeedMem
#endif
#ifdef F_sceAudiocodec_0002
IMPORT_FUNC "sceAudiocodec",0x5B37EB1D,sceAudiocodecInit
#endif
#ifdef F_sceAudiocodec_0003
IMPORT_FUNC "sceAudiocodec",0x70A703F8,sceAudiocodecDecode
#endif
#ifdef F_sceAudiocodec_0004
IMPORT_FUNC "sceAudiocodec",0x8ACA11D5,sceAudiocodecGetInfo
#endif
#ifdef F_sceAudiocodec_0005
IMPORT_FUNC "sceAudiocodec",0x6CD2A861,sceAudiocodec_6CD2A861
#endif
#ifdef F_sceAudiocodec_0006
IMPORT_FUNC "sceAudiocodec",0x59176A0F,sceAudiocodec_59176A0F
#endif
#ifdef F_sceAudiocodec_0007
IMPORT_FUNC "sceAudiocodec",0x3A20A200,sceAudiocodecGetEDRAM
#endif
#ifdef F_sceAudiocodec_0008
IMPORT_FUNC "sceAudiocodec",0x29681260,sceAudiocodecReleaseEDRAM
#endif

17
src/base/Makefile.am Normal file
View File

@@ -0,0 +1,17 @@
pspsdkincludedir = @PSPSDK_INCLUDEDIR@
pspsdkinclude_HEADERS = \
as_reg_compat.h \
psptypes.h \
pspstub.s \
pspimport.s
## Install the build.mak fragment to $PSPSDK/lib.
buildmakdir = @PSPSDK_LIBDIR@
buildmak_DATA = build.mak prxspecs
buildmakprxdir = @PSPSDK_LIBDIR@
buildmakprx_DATA = build_prx.mak linkfile.prx
EXTRA_DIST = build.mak prxspecs build_prx.mak linkfile.prx

52
src/base/as_reg_compat.h Normal file
View File

@@ -0,0 +1,52 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* as_reg_compat.h - Register name mapping.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: as_reg_compat.h 540 2005-07-08 19:35:10Z warren $
*/
#ifndef __AS_REG_COMPAT_H__
#define __AS_REG_COMPAT_H__
/* register defines for the GNU assembler */
#define zero 0
#define at 1
#define v0 2
#define v1 3
#define a0 4
#define a1 5
#define a2 6
#define a3 7
#define t0 8
#define t1 9
#define t2 10
#define t3 11
#define t4 12
#define t5 13
#define t6 14
#define t7 15
#define s0 16
#define s1 17
#define s2 18
#define s3 19
#define s4 20
#define s5 21
#define s6 22
#define s7 23
#define t8 24
#define t9 25
#define k0 26
#define k1 27
#define gp 28
#define sp 29
#define fp 30
#define ra 31
#endif

204
src/base/build.mak Normal file
View File

@@ -0,0 +1,204 @@
# PSP Software Development Kit - http://www.pspdev.org
# -----------------------------------------------------------------------
# Licensed under the BSD license, see LICENSE in PSPSDK root for details.
#
# build.mak - Base makefile for projects using PSPSDK.
#
# Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
# Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
# Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
#
# $Id: build.mak 2333 2007-10-31 19:37:40Z tyranid $
# Note: The PSPSDK make variable must be defined before this file is included.
ifeq ($(PSPSDK),)
$(error $$(PSPSDK) is undefined. Use "PSPSDK := $$(shell psp-config --pspsdk-path)" in your Makefile)
endif
CC = psp-gcc
CXX = psp-g++
AS = psp-gcc
LD = psp-gcc
AR = psp-ar
RANLIB = psp-ranlib
STRIP = psp-strip
MKSFO = mksfo
PACK_PBP = pack-pbp
FIXUP = psp-fixup-imports
# Add in PSPSDK includes and libraries.
INCDIR := $(INCDIR) . $(PSPSDK)/include
LIBDIR := $(LIBDIR) . $(PSPSDK)/lib
CFLAGS := $(addprefix -I,$(INCDIR)) $(CFLAGS)
CXXFLAGS := $(CFLAGS) $(CXXFLAGS)
ASFLAGS := $(CFLAGS) $(ASFLAGS)
ifeq ($(PSP_LARGE_MEMORY),1)
MKSFO = mksfoex -d MEMSIZE=1
endif
ifeq ($(PSP_FW_VERSION),)
PSP_FW_VERSION=150
endif
CFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
CXXFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
ifeq ($(BUILD_PRX),1)
LDFLAGS := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS)
EXTRA_CLEAN += $(TARGET).elf
# Setup default exports if needed
ifdef PRX_EXPORTS
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS))
EXTRA_CLEAN += $(EXPORT_OBJ)
else
EXPORT_OBJ=$(PSPSDK)/lib/prxexports.o
endif
else
LDFLAGS := $(addprefix -L,$(LIBDIR)) $(LDFLAGS)
endif
# Library selection. By default we link with Newlib's libc. Allow the
# user to link with PSPSDK's libc if USE_PSPSDK_LIBC is set to 1.
ifeq ($(USE_KERNEL_LIBC),1)
# Use the PSP's kernel libc
PSPSDK_LIBC_LIB =
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else
ifeq ($(USE_PSPSDK_LIBC),1)
# Use the pspsdk libc
PSPSDK_LIBC_LIB = -lpsplibc
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else
# Use newlib (urgh)
PSPSDK_LIBC_LIB = -lc
endif
endif
# Link with following default libraries. Other libraries should be specified in the $(LIBS) variable.
# TODO: This library list needs to be generated at configure time.
#
ifeq ($(USE_KERNEL_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay_driver -lpspctrl_driver -lpspsdk
LIBS := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspkernel
else
ifeq ($(USE_USER_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspnet \
-lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility \
-lpspuser
else
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspnet \
-lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility \
-lpspuser -lpspkernel
endif
endif
# Define the overridable parameters for EBOOT.PBP
ifndef PSP_EBOOT_TITLE
PSP_EBOOT_TITLE = $(TARGET)
endif
ifndef PSP_EBOOT_SFO
PSP_EBOOT_SFO = PARAM.SFO
endif
ifndef PSP_EBOOT_ICON
PSP_EBOOT_ICON = NULL
endif
ifndef PSP_EBOOT_ICON1
PSP_EBOOT_ICON1 = NULL
endif
ifndef PSP_EBOOT_UNKPNG
PSP_EBOOT_UNKPNG = NULL
endif
ifndef PSP_EBOOT_PIC1
PSP_EBOOT_PIC1 = NULL
endif
ifndef PSP_EBOOT_SND0
PSP_EBOOT_SND0 = NULL
endif
ifndef PSP_EBOOT_PSAR
PSP_EBOOT_PSAR = NULL
endif
ifndef PSP_EBOOT
PSP_EBOOT = EBOOT.PBP
endif
ifeq ($(BUILD_PRX),1)
ifneq ($(TARGET_LIB),)
$(error TARGET_LIB should not be defined when building a prx)
else
FINAL_TARGET = $(TARGET).prx
endif
else
ifneq ($(TARGET_LIB),)
FINAL_TARGET = $(TARGET_LIB)
else
FINAL_TARGET = $(TARGET).elf
endif
endif
all: $(EXTRA_TARGETS) $(FINAL_TARGET)
kxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
mkdir -p "$(TARGET)"
$(STRIP) $(TARGET).elf -o $(TARGET)/$(PSP_EBOOT)
mkdir -p "$(TARGET)%"
$(PACK_PBP) "$(TARGET)%/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)
SCEkxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
mkdir -p "__SCE__$(TARGET)"
$(STRIP) $(TARGET).elf -o __SCE__$(TARGET)/$(PSP_EBOOT)
mkdir -p "%__SCE__$(TARGET)"
$(PACK_PBP) "%__SCE__$(TARGET)/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)
$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
$(LINK.c) $^ $(LIBS) -o $@
$(FIXUP) $@
$(TARGET_LIB): $(OBJS)
$(AR) cru $@ $(OBJS)
$(RANLIB) $@
$(PSP_EBOOT_SFO):
$(MKSFO) '$(PSP_EBOOT_TITLE)' $@
ifeq ($(BUILD_PRX),1)
$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO)
$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) $(TARGET).prx $(PSP_EBOOT_PSAR)
else
$(PSP_EBOOT): $(TARGET).elf $(PSP_EBOOT_SFO)
$(STRIP) $(TARGET).elf -o $(TARGET)_strip.elf
$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \
$(PSP_EBOOT_SND0) $(TARGET)_strip.elf $(PSP_EBOOT_PSAR)
-rm -f $(TARGET)_strip.elf
endif
%.prx: %.elf
psp-prxgen $< $@
%.c: %.exp
psp-build-exports -b $< > $@
clean:
-rm -f $(FINAL_TARGET) $(EXTRA_CLEAN) $(OBJS) $(PSP_EBOOT_SFO) $(PSP_EBOOT) $(EXTRA_TARGETS)
rebuild: clean all

86
src/base/build_prx.mak Normal file
View File

@@ -0,0 +1,86 @@
# PSP Software Development Kit - http://www.pspdev.org
# -----------------------------------------------------------------------
# Licensed under the BSD license, see LICENSE in PSPSDK root for details.
#
# build.mak - Base makefile for projects using PSPSDK.
#
# Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
# Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
# Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
#
# $Id: build.mak 771 2005-07-24 10:43:54Z tyranid $
# Note: The PSPSDK make variable must be defined before this file is included.
ifeq ($(PSPSDK),)
$(error $$(PSPSDK) is undefined. Use "PSPSDK := $$(shell psp-config --pspsdk-path)" in your Makefile)
endif
CC = psp-gcc
CXX = psp-g++
AS = psp-gcc
LD = psp-gcc
FIXUP = psp-fixup-imports
# Add in PSPSDK includes and libraries.
INCDIR := $(INCDIR) . $(PSPSDK)/include
LIBDIR := $(LIBDIR) . $(PSPSDK)/lib
CFLAGS := $(addprefix -I,$(INCDIR)) $(CFLAGS)
CXXFLAGS := $(CFLAGS) $(CXXFLAGS)
ASFLAGS := $(CFLAGS) $(ASFLAGS)
LDFLAGS := $(addprefix -L,$(LIBDIR)) -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx -mno-crt0 -nostartfiles $(LDFLAGS)
ifeq ($(PSP_FW_VERSION),)
PSP_FW_VERSION=150
endif
CFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)
# Library selection. By default we link with Newlib's libc. Allow the
# user to link with PSPSDK's libc if USE_PSPSDK_LIBC is set to 1.
ifeq ($(USE_KERNEL_LIBC),1)
# Use the PSP's kernel libc
PSPSDK_LIBC_LIB =
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else
ifeq ($(USE_PSPSDK_LIBC),1)
# Use the pspsdk libc
PSPSDK_LIBC_LIB = -lpsplibc
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else
# Use newlib (urgh)
PSPSDK_LIBC_LIB = -lc
endif
endif
# Link with following default libraries. Other libraries should be specified in the $(LIBS) variable.
# TODO: This library list needs to be generated at configure time.
ifeq ($(USE_KERNEL_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay_driver -lpspctrl_driver -lpspsdk
LIBS := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspkernel
else
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpsputility -lpspuser -lpspkernel
endif
FINAL_TARGET = $(TARGET).prx
all: $(FINAL_TARGET)
$(TARGET).elf: $(OBJS)
$(LINK.c) $^ $(LIBS) -o $@
$(FIXUP) $@
%.prx: %.elf
psp-prxgen $< $@
%.c: %.exp
psp-build-exports -b $< > $@
clean: $(EXTRA_CLEAN)
-rm -f $(FINAL_TARGET) $(TARGET).elf $(OBJS)
rebuild: clean all

246
src/base/linkfile.prx.in Normal file
View File

@@ -0,0 +1,246 @@
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
"elf32-littlemips")
OUTPUT_ARCH(mips:allegrex)
ENTRY(module_start)
SEARCH_DIR("@PSPDEV_LIBDIR@");
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = 0x0); . = 0x0;
.interp : { *(.interp) }
.dynamic : { *(.dynamic) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.text : { *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) }
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
/* PSP-specific relocations. */
.rel.sceStub.text : { *(.rel.sceStub.text) *(SORT(.rel.sceStub.text.*)) }
.rel.lib.ent.top : { *(.rel.lib.ent.top) }
.rel.lib.ent : { *(.rel.lib.ent) }
.rel.lib.ent.btm : { *(.rel.lib.ent.btm) }
.rel.lib.stub.top : { *(.rel.lib.stub.top) }
.rel.lib.stub : { *(.rel.lib.stub) }
.rel.lib.stub.btm : { *(.rel.lib.stub.btm) }
.rel.rodata.sceModuleInfo : { *(.rel.rodata.sceModuleInfo) }
.rel.rodata.sceResident : { *(.rel.rodata.sceResident) }
.rel.rodata.sceNid : { *(.rel.rodata.sceNid) }
.rel.rodata.sceVstub : { *(.rel.rodata.sceVstub) *(SORT(.rel.rodata.sceVstub.*)) }
.rel.rodata : { *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.rel.data.rel.ro : { *(.rel.data.rel.ro*) }
.rela.data.rel.ro : { *(.rel.data.rel.ro*) }
.rel.data : { *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rel.tdata : { *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) }
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
.rel.tbss : { *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) }
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.sdata : { *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) }
.rela.sdata : { *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) }
.rel.sbss : { *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) }
.rela.sbss : { *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) }
.rel.sdata2 : { *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) }
.rela.sdata2 : { *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) }
.rel.sbss2 : { *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) }
.rela.sbss2 : { *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) }
.rel.bss : { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) }
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.text :
{
_ftext = . ;
*(.text .stub .text.* .gnu.linkonce.t.*)
KEEP (*(.text.*personality*))
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.mips16.fn.*) *(.mips16.call.*)
} =0
.init :
{
KEEP (*(.init))
} =0
.plt : { *(.plt) }
.fini :
{
KEEP (*(.fini))
} =0
/* PSP library stub functions. */
.sceStub.text : { *(.sceStub.text) *(SORT(.sceStub.text.*)) }
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
/* PSP library entry table and library stub table. */
.lib.ent.top : { *(.lib.ent.top) }
.lib.ent : { *(.lib.ent) }
.lib.ent.btm : { *(.lib.ent.btm) }
.lib.stub.top : { *(.lib.stub.top) }
.lib.stub : { *(.lib.stub) }
.lib.stub.btm : { *(.lib.stub.btm) }
/* PSP read-only data for module info, NIDs, and Vstubs. The
.rodata.sceModuleInfo section must appear before the .rodata section
otherwise it would get absorbed into .rodata and the PSP bootloader
would be unable to locate the module info structure. */
.rodata.sceModuleInfo : { *(.rodata.sceModuleInfo) }
.rodata.sceResident : { *(.rodata.sceResident) }
.rodata.sceNid : { KEEP (*(.rodata.sceNid)) }
.rodata.sceVstub : { *(.rodata.sceVstub) *(SORT(.rodata.sceVstub.*)) }
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
.sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(256) + (. & (256 - 1));
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
/* Ensure the __preinit_array_start label is properly aligned. We
could instead move the label definition inside the section, but
the linker would then create the section even if it turns out to
be empty, which isn't pretty. */
. = ALIGN(32 / 8);
PROVIDE (__preinit_array_start = .);
.preinit_array : { KEEP (*(.preinit_array)) }
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
.init_array : { KEEP (*(.init_array)) }
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
.fini_array : { KEEP (*(.fini_array)) }
PROVIDE (__fini_array_end = .);
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
.data :
{
_fdata = . ;
*(.data .data.* .gnu.linkonce.d.*)
KEEP (*(.gnu.linkonce.d.*personality*))
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
. = .;
_gp = ALIGN(16) + 0x7ff0;
.got : { *(.got.plt) *(.got) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
*(.sdata .sdata.* .gnu.linkonce.s.*)
}
.lit8 : { *(.lit8) }
.lit4 : { *(.lit4) }
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
_fbss = .;
.sbss :
{
PROVIDE (__sbss_start = .);
PROVIDE (___sbss_start = .);
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
PROVIDE (__sbss_end = .);
PROVIDE (___sbss_end = .);
}
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
_end = .;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/DISCARD/ : { *(.comment) *(.pdr) }
/DISCARD/ : { *(.note.GNU-stack) }
}

2
src/base/prxspecs Normal file
View File

@@ -0,0 +1,2 @@
*startfile:
crt0_prx%O%s crti%O%s crtbegin%O%s

68
src/base/pspimport.s Normal file
View File

@@ -0,0 +1,68 @@
.macro IMPORT_START module, flags_ver
.set push
.section .rodata.sceResident, "a"
.word 0
__stub_modulestr_\module:
.asciz "\module"
.align 2
.section .lib.stub, "a", @progbits
.global __stub_module_\module
__stub_module_\module:
.word __stub_modulestr_\module
.word \flags_ver
.word 0x5
.word __executable_start
.word __executable_start
.set pop
.endm
.macro IMPORT_FUNC module, funcid, funcname
.set push
.set noreorder
.extern __stub_module_\module
.section .sceStub.text, "ax", @progbits
.globl \funcname
.type \funcname, @function
.ent \funcname, 0
\funcname:
.word __stub_module_\module
.word \funcid
.end \funcname
.size \funcname, .-\funcname
.section .rodata.sceNid, "a"
.word \funcid
.set pop
.endm
.macro IMPORT_FUNC_WITH_ALIAS module, funcid, funcname, alias
.set push
.set noreorder
.extern __stub_module_\module
.section .sceStub.text, "ax", @progbits
.globl \alias
.type \alias, @function
\alias:
.globl \funcname
.type \funcname, @function
.ent \funcname, 0
\funcname:
.word __stub_module_\module
.word \funcid
.end \funcname
.size \funcname, .-\funcname
.section .rodata.sceNid, "a"
.word \funcid
.set pop
.endm

83
src/base/pspstub.s Normal file
View File

@@ -0,0 +1,83 @@
# common.s - GAS macros for creating import libraries.
#
# Use STUB_START to declare the start of an import library. The module parameter
# is the name of the library to import, flags_ver is both the import flags and library
# version, and stub_len is both the number of stubs to import and the size of the
# stub itself (in 32-bit words).
# Use the STUB_FUNC macro for each stub you want to import. The funcid parameter is
# the 32-bit SHA1-derived NID value, and the funcname is the name you want to call
# the imported function.
# Use STUB_END to declare the end of your import library.
.macro STUB_START module, flags_ver, stub_len
.set push
.section .rodata.sceResident, "a"
.word 0
__stub_modulestr_\module:
.asciz "\module"
.align 2
.section .lib.stub, "a", @progbits
.word __stub_modulestr_\module
.word \flags_ver
.word \stub_len
.word __stub_idtable_\module
.word __stub_text_\module
.section .rodata.sceNid, "a"
__stub_idtable_\module:
.section .sceStub.text, "ax", @progbits
__stub_text_\module:
.set pop
.endm
.macro STUB_FUNC funcid, funcname
.set push
.set noreorder
.section .sceStub.text, "ax", @progbits
.globl \funcname
.type \funcname, @function
.ent \funcname, 0
\funcname:
jr $ra
nop
.end \funcname
.size \funcname, .-\funcname
.section .rodata.sceNid
.word \funcid
.set pop
.endm
.macro STUB_FUNC_WITH_ALIAS funcid, funcname, alias
.set push
.set noreorder
.section .sceStub.text, "ax", @progbits
.globl \alias
.type \alias, @function
\alias:
.globl \funcname
.type \funcname, @function
.ent \funcname, 0
\funcname:
jr $ra
nop
.end \funcname
.size \funcname, .-\funcname
.section .rodata.sceNid
.word \funcid
.set pop
.endm
.macro STUB_END
.endm

434
src/base/psptypes.h Normal file
View File

@@ -0,0 +1,434 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* psptypes.h - Commonly used typedefs.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: psptypes.h 2312 2007-09-09 15:02:23Z chip $
*/
/* Note: Some of the structures, types, and definitions in this file were
extrapolated from symbolic debugging information found in the Japanese
version of Puzzle Bobble. */
#ifndef _PSPTYPES_H_
#define _PSPTYPES_H_ 1
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *) 0)
#endif /* __cplusplus */
#endif
/* Legacy ps2dev types. */
#ifndef PSP_LEGACY_TYPES_DEFINED
#define PSP_LEGACY_TYPES_DEFINED
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
#endif
#ifndef PSP_LEGACY_VOLATILE_TYPES_DEFINED
#define PSP_LEGACY_VOLATILE_TYPES_DEFINED
typedef volatile uint8_t vu8;
typedef volatile uint16_t vu16;
typedef volatile uint32_t vu32;
typedef volatile uint64_t vu64;
typedef volatile int8_t vs8;
typedef volatile int16_t vs16;
typedef volatile int32_t vs32;
typedef volatile int64_t vs64;
#endif
/* MIPS-like accessor macros. */
static __inline__ u8 _lb(u32 addr) { return *(vu8 *)addr; }
static __inline__ u16 _lh(u32 addr) { return *(vu16 *)addr; }
static __inline__ u32 _lw(u32 addr) { return *(vu32 *)addr; }
static __inline__ u64 _ld(u32 addr) { return *(vu64 *)addr; }
static __inline__ void _sb(u8 val, u32 addr) { *(vu8 *)addr = val; }
static __inline__ void _sh(u16 val, u32 addr) { *(vu16 *)addr = val; }
static __inline__ void _sw(u32 val, u32 addr) { *(vu32 *)addr = val; }
static __inline__ void _sd(u64 val, u32 addr) { *(vu64 *)addr = val; }
/* SCE types. */
typedef unsigned char SceUChar8;
typedef uint16_t SceUShort16;
typedef uint32_t SceUInt32;
typedef uint64_t SceUInt64;
typedef uint64_t SceULong64;
/*typedef unsigned int SceULong128 __attribute__((mode(TI)));*/
typedef char SceChar8;
typedef int16_t SceShort16;
typedef int32_t SceInt32;
typedef int64_t SceInt64;
typedef int64_t SceLong64;
/*typedef int SceLong128 __attribute__((mode(TI)));*/
typedef float SceFloat;
typedef float SceFloat32;
typedef short unsigned int SceWChar16;
typedef unsigned int SceWChar32;
typedef int SceBool;
typedef void SceVoid;
typedef void * ScePVoid;
/* PSP types. */
/* Rectangles. */
typedef struct ScePspSRect {
short int x;
short int y;
short int w;
short int h;
} ScePspSRect;
typedef struct ScePspIRect {
int x;
int y;
int w;
int h;
} ScePspIRect;
typedef struct ScePspL64Rect {
SceLong64 x;
SceLong64 y;
SceLong64 w;
SceLong64 h;
} ScePspL64Rect;
typedef struct ScePspFRect {
float x;
float y;
float w;
float h;
} ScePspFRect;
/* 2D vectors. */
typedef struct ScePspSVector2 {
short int x;
short int y;
} ScePspSVector2;
typedef struct ScePspIVector2 {
int x;
int y;
} ScePspIVector2;
typedef struct ScePspL64Vector2 {
SceLong64 x;
SceLong64 y;
} ScePspL64Vector2;
typedef struct ScePspFVector2 {
float x;
float y;
} ScePspFVector2;
typedef union ScePspVector2 {
ScePspFVector2 fv;
ScePspIVector2 iv;
float f[2];
int i[2];
} ScePspVector2;
/* 3D vectors. */
typedef struct ScePspSVector3 {
short int x;
short int y;
short int z;
} ScePspSVector3;
typedef struct ScePspIVector3 {
int x;
int y;
int z;
} ScePspIVector3;
typedef struct ScePspL64Vector3 {
SceLong64 x;
SceLong64 y;
SceLong64 z;
} ScePspL64Vector3;
typedef struct ScePspFVector3 {
float x;
float y;
float z;
} ScePspFVector3;
typedef union ScePspVector3 {
ScePspFVector3 fv;
ScePspIVector3 iv;
float f[3];
int i[3];
} ScePspVector3;
/* 4D vectors. */
typedef struct ScePspSVector4 {
short int x;
short int y;
short int z;
short int w;
} ScePspSVector4;
typedef struct ScePspIVector4 {
int x;
int y;
int z;
int w;
} ScePspIVector4;
typedef struct ScePspL64Vector4 {
SceLong64 x;
SceLong64 y;
SceLong64 z;
SceLong64 w;
} ScePspL64Vector4;
typedef struct ScePspFVector4 {
float x;
float y;
float z;
float w;
} ScePspFVector4 __attribute__((aligned(16)));
typedef struct ScePspFVector4Unaligned {
float x;
float y;
float z;
float w;
} ScePspFVector4Unaligned;
typedef union ScePspVector4 {
ScePspFVector4 fv;
ScePspIVector4 iv;
/* SceULong128 qw;*/ /* Missing compiler support. */
float f[4];
int i[4];
} ScePspVector4 __attribute__((aligned(16)));
/* 2D matrix types. */
typedef struct ScePspIMatrix2 {
ScePspIVector2 x;
ScePspIVector2 y;
} ScePspIMatrix2;
typedef struct ScePspFMatrix2 {
ScePspFVector2 x;
ScePspFVector2 y;
} ScePspFMatrix2;
typedef union ScePspMatrix2 {
ScePspFMatrix2 fm;
ScePspIMatrix2 im;
ScePspFVector2 fv[2];
ScePspIVector2 iv[2];
ScePspVector2 v[2];
/* SceULong128 qw[2];*/ /* Missing compiler support. */
float f[2][2];
int i[2][2];
} ScePspMatrix2;
/* 3D matrix types. */
typedef struct ScePspIMatrix3 {
ScePspIVector3 x;
ScePspIVector3 y;
ScePspIVector3 z;
} ScePspIMatrix3;
typedef struct ScePspFMatrix3 {
ScePspFVector3 x;
ScePspFVector3 y;
ScePspFVector3 z;
} ScePspFMatrix3;
typedef union ScePspMatrix3 {
ScePspFMatrix3 fm;
ScePspIMatrix3 im;
ScePspFVector3 fv[3];
ScePspIVector3 iv[3];
ScePspVector3 v[3];
/* SceULong128 qw[3];*/ /* Missing compiler support. */
float f[3][3];
int i[3][3];
} ScePspMatrix3;
/* 4D matrix types. */
typedef struct ScePspIMatrix4 {
ScePspIVector4 x;
ScePspIVector4 y;
ScePspIVector4 z;
ScePspIVector4 w;
} ScePspIMatrix4 __attribute__((aligned(16)));
typedef struct ScePspIMatrix4Unaligned {
ScePspIVector4 x;
ScePspIVector4 y;
ScePspIVector4 z;
ScePspIVector4 w;
} ScePspIMatrix4Unaligned;
typedef struct ScePspFMatrix4 {
ScePspFVector4 x;
ScePspFVector4 y;
ScePspFVector4 z;
ScePspFVector4 w;
} ScePspFMatrix4 __attribute__((aligned(16)));
typedef struct ScePspFMatrix4Unaligned {
ScePspFVector4 x;
ScePspFVector4 y;
ScePspFVector4 z;
ScePspFVector4 w;
} ScePspFMatrix4Unaligned;
typedef union ScePspMatrix4 {
ScePspFMatrix4 fm;
ScePspIMatrix4 im;
ScePspFVector4 fv[4];
ScePspIVector4 iv[4];
ScePspVector4 v[4];
/* SceULong128 qw[4];*/ /* Missing compiler support. */
float f[4][4];
int i[4][4];
} ScePspMatrix4;
/* Quaternions. */
typedef struct ScePspFQuaternion {
float x;
float y;
float z;
float w;
} ScePspFQuaternion __attribute__((aligned(16)));
typedef struct ScePspFQuaternionUnaligned {
float x;
float y;
float z;
float w;
} ScePspFQuaternionUnaligned;
/* Colors and pixel formats. */
typedef struct ScePspFColor {
float r;
float g;
float b;
float a;
} ScePspFColor __attribute__((aligned(16)));
typedef struct ScePspFColorUnaligned {
float r;
float g;
float b;
float a;
} ScePspFColorUnaligned;
typedef unsigned int ScePspRGBA8888;
typedef unsigned short ScePspRGBA4444;
typedef unsigned short ScePspRGBA5551;
typedef unsigned short ScePspRGB565;
/* Unions for converting between types. */
typedef union ScePspUnion32 {
unsigned int ui;
int i;
unsigned short us[2];
short int s[2];
unsigned char uc[4];
char c[4];
float f;
ScePspRGBA8888 rgba8888;
ScePspRGBA4444 rgba4444[2];
ScePspRGBA5551 rgba5551[2];
ScePspRGB565 rgb565[2];
} ScePspUnion32;
typedef union ScePspUnion64 {
SceULong64 ul;
SceLong64 l;
unsigned int ui[2];
int i[2];
unsigned short us[4];
short int s[4];
unsigned char uc[8];
char c[8];
float f[2];
ScePspSRect sr;
ScePspSVector4 sv;
ScePspRGBA8888 rgba8888[2];
ScePspRGBA4444 rgba4444[4];
ScePspRGBA5551 rgba5551[4];
ScePspRGB565 rgb565[4];
} ScePspUnion64;
typedef union ScePspUnion128 {
/* SceULong128 qw;*/ /* Missing compiler support. */
/* SceULong128 uq;*/
/* SceLong128 q;*/
SceULong64 ul[2];
SceLong64 l[2];
unsigned int ui[4];
int i[4];
unsigned short us[8];
short int s[8];
unsigned char uc[16];
char c[16];
float f[4];
ScePspFRect fr;
ScePspIRect ir;
ScePspFVector4 fv;
ScePspIVector4 iv;
ScePspFQuaternion fq;
ScePspFColor fc;
ScePspRGBA8888 rgba8888[4];
ScePspRGBA4444 rgba4444[8];
ScePspRGBA5551 rgba5551[8];
ScePspRGB565 rgb565[8];
} ScePspUnion128 __attribute__((aligned(16)));
/* Date and time. */
typedef struct ScePspDateTime {
unsigned short year;
unsigned short month;
unsigned short day;
unsigned short hour;
unsigned short minute;
unsigned short second;
unsigned int microsecond;
} ScePspDateTime;
#ifdef __cplusplus
}
#endif
#endif /* _PSPTYPES_H_ */

32
src/ctrl/Makefile.am Normal file
View File

@@ -0,0 +1,32 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
CTRL_OBJS = sceCtrl_0000.o sceCtrl_0001.o sceCtrl_0002.o sceCtrl_0003.o sceCtrl_0004.o sceCtrl_0005.o sceCtrl_0006.o sceCtrl_0007.o sceCtrl_0008.o sceCtrl_0009.o sceCtrl_0010.o sceCtrl_0011.o sceCtrl_0012.o sceCtrl_0013.o sceCtrl_0014.o sceCtrl_0015.o sceCtrl_0016.o
CTRLDRIVER_OBJS = sceCtrl_driver_0000.o sceCtrl_driver_0001.o sceCtrl_driver_0002.o sceCtrl_driver_0003.o sceCtrl_driver_0004.o sceCtrl_driver_0005.o sceCtrl_driver_0006.o sceCtrl_driver_0007.o sceCtrl_driver_0008.o sceCtrl_driver_0009.o sceCtrl_driver_0010.o sceCtrl_driver_0011.o sceCtrl_driver_0012.o sceCtrl_driver_0013.o sceCtrl_driver_0014.o sceCtrl_driver_0015.o sceCtrl_driver_0016.o sceCtrl_driver_0017.o sceCtrl_driver_0018.o sceCtrl_driver_0019.o sceCtrl_driver_0020.o sceCtrl_driver_0021.o sceCtrl_driver_0022.o sceCtrl_driver_0023.o sceCtrl_driver_0024.o sceCtrl_driver_0025.o
libpspctrlincludedir = @PSPSDK_INCLUDEDIR@
libpspctrlinclude_HEADERS = pspctrl.h pspctrl_kernel.h
lib_LIBRARIES = libpspctrl.a libpspctrl_driver.a
libpspctrl_a_SOURCES = sceCtrl.S
libpspctrl_a_LIBADD = $(CTRL_OBJS)
libpspctrl_driver_a_SOURCES = sceCtrl_driver.S
libpspctrl_driver_a_LIBADD = $(CTRLDRIVER_OBJS)
$(CTRL_OBJS): sceCtrl.S
$(COMPILE) -DF_$* $< -c -o $@
$(CTRLDRIVER_OBJS): sceCtrl_driver.S
$(COMPILE) -DF_$* $< -c -o $@

206
src/ctrl/pspctrl.h Normal file
View File

@@ -0,0 +1,206 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspctrl.h - Prototypes for the sceCtrl library.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: pspctrl.h 2433 2008-10-15 10:00:27Z iwn $
*/
/* Note: Some of the structures, types, and definitions in this file were
extrapolated from symbolic debugging information found in the Japanese
version of Puzzle Bobble. */
#ifndef __CTRL_H__
#define __CTRL_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup Ctrl Controller Kernel Library */
/*@{*/
/**
* Enumeration for the digital controller buttons.
*
* @note PSP_CTRL_HOME, PSP_CTRL_NOTE, PSP_CTRL_SCREEN, PSP_CTRL_VOLUP, PSP_CTRL_VOLDOWN, PSP_CTRL_DISC, PSP_CTRL_WLAN_UP, PSP_CTRL_REMOTE, PSP_CTRL_MS can only be read in kernel mode
*/
enum PspCtrlButtons
{
/** Select button. */
PSP_CTRL_SELECT = 0x000001,
/** Start button. */
PSP_CTRL_START = 0x000008,
/** Up D-Pad button. */
PSP_CTRL_UP = 0x000010,
/** Right D-Pad button. */
PSP_CTRL_RIGHT = 0x000020,
/** Down D-Pad button. */
PSP_CTRL_DOWN = 0x000040,
/** Left D-Pad button. */
PSP_CTRL_LEFT = 0x000080,
/** Left trigger. */
PSP_CTRL_LTRIGGER = 0x000100,
/** Right trigger. */
PSP_CTRL_RTRIGGER = 0x000200,
/** Triangle button. */
PSP_CTRL_TRIANGLE = 0x001000,
/** Circle button. */
PSP_CTRL_CIRCLE = 0x002000,
/** Cross button. */
PSP_CTRL_CROSS = 0x004000,
/** Square button. */
PSP_CTRL_SQUARE = 0x008000,
/** Home button. In user mode this bit is set if the exit dialog is visible. */
PSP_CTRL_HOME = 0x010000,
/** Hold button. */
PSP_CTRL_HOLD = 0x020000,
/** Music Note button. */
PSP_CTRL_NOTE = 0x800000,
/** Screen button. */
PSP_CTRL_SCREEN = 0x400000,
/** Volume up button. */
PSP_CTRL_VOLUP = 0x100000,
/** Volume down button. */
PSP_CTRL_VOLDOWN = 0x200000,
/** Wlan switch up. */
PSP_CTRL_WLAN_UP = 0x040000,
/** Remote hold position. */
PSP_CTRL_REMOTE = 0x080000,
/** Disc present. */
PSP_CTRL_DISC = 0x1000000,
/** Memory stick present. */
PSP_CTRL_MS = 0x2000000,
};
/** Controller mode. */
enum PspCtrlMode
{
/* Digitial. */
PSP_CTRL_MODE_DIGITAL = 0,
/* Analog. */
PSP_CTRL_MODE_ANALOG
};
/** Returned controller data */
typedef struct SceCtrlData {
/** The current read frame. */
unsigned int TimeStamp;
/** Bit mask containing zero or more of ::PspCtrlButtons. */
unsigned int Buttons;
/** Analogue stick, X axis. */
unsigned char Lx;
/** Analogue stick, Y axis. */
unsigned char Ly;
/** Reserved. */
unsigned char Rsrv[6];
} SceCtrlData;
typedef struct SceCtrlLatch {
unsigned int uiMake;
unsigned int uiBreak;
unsigned int uiPress;
unsigned int uiRelease;
} SceCtrlLatch;
/**
* Set the controller cycle setting.
*
* @param cycle - Cycle. Normally set to 0.
*
* @return The previous cycle setting.
*/
int sceCtrlSetSamplingCycle(int cycle);
/**
* Get the controller current cycle setting.
*
* @param pcycle - Return value.
*
* @return 0.
*/
int sceCtrlGetSamplingCycle(int *pcycle);
/**
* Set the controller mode.
*
* @param mode - One of ::PspCtrlMode.
*
* @return The previous mode.
*/
int sceCtrlSetSamplingMode(int mode);
/**
* Get the current controller mode.
*
* @param pmode - Return value.
*
* @return 0.
*/
int sceCtrlGetSamplingMode(int *pmode);
int sceCtrlPeekBufferPositive(SceCtrlData *pad_data, int count);
int sceCtrlPeekBufferNegative(SceCtrlData *pad_data, int count);
/**
* Read buffer positive
*
* @par Example:
* @code
* SceCtrlData pad;
* sceCtrlSetSamplingCycle(0);
* sceCtrlSetSamplingMode(1);
* sceCtrlReadBufferPositive(&pad, 1);
* // Do something with the read controller data
* @endcode
*
* @param pad_data - Pointer to a ::SceCtrlData structure used hold the returned pad data.
* @param count - Number of ::SceCtrlData buffers to read.
*/
int sceCtrlReadBufferPositive(SceCtrlData *pad_data, int count);
int sceCtrlReadBufferNegative(SceCtrlData *pad_data, int count);
int sceCtrlPeekLatch(SceCtrlLatch *latch_data);
int sceCtrlReadLatch(SceCtrlLatch *latch_data);
/**
* Set analog threshold relating to the idle timer.
*
* @param idlereset - Movement needed by the analog to reset the idle timer.
* @param idleback - Movement needed by the analog to bring the PSP back from an idle state.
*
* Set to -1 for analog to not cancel idle timer.
* Set to 0 for idle timer to be cancelled even if the analog is not moved.
* Set between 1 - 128 to specify the movement on either axis needed by the analog to fire the event.
*
* @return < 0 on error.
*/
int sceCtrlSetIdleCancelThreshold(int idlereset, int idleback);
/**
* Get the idle threshold values.
*
* @param idlerest - Movement needed by the analog to reset the idle timer.
* @param idleback - Movement needed by the analog to bring the PSP back from an idle state.
*
* @return < 0 on error.
*/
int sceCtrlGetIdleCancelThreshold(int *idlerest, int *idleback);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif

70
src/ctrl/pspctrl_kernel.h Normal file
View File

@@ -0,0 +1,70 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspctrl_kernel.h - Prototypes for the sceCtrl_driver library.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: pspctrl_kernel.h 2433 2008-10-15 10:00:27Z iwn $
*/
#ifndef __CTRL_KERNEL_H__
#define __CTRL_KERNEL_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* Set the controller button masks
*
* @param mask - The bits to setup
* @param type - The type of operation (0 clear, 1 set mask, 2 set button)
*
* @par Example:
* @code
* sceCtrl_driver_7CA723DC(0xFFFF, 1); // Mask lower 16bits
* sceCtrl_driver_7CA723DC(0x10000, 2); // Always return HOME key
* // Do something
* sceCtrl_driver_7CA723DC(0x10000, 0); // Unset HOME key
* sceCtrl_driver_7CA723DC(0xFFFF, 0); // Unset mask
* @endcode
*/
void sceCtrl_driver_7CA723DC(unsigned int mask, unsigned type);
/**
* Get button mask mode
*
* @param mask - The bitmask to check
*
* @return 0 no setting, 1 set in button mask, 2 set in button set
*/
int sceCtrl_driver_5E77BC8A(unsigned int mask);
/**
* Setup a controller callback
*
* @param no - The number of the callback (0-3)
* @param mask - The bits to check for
* @param cb - The callback function (int curr_but, int last_but, void *arg)
* @param arg - User defined argument passed
*
* @return 0 on success, < 0 on error
*/
int sceCtrl_driver_5C56C779(int no, unsigned int mask, void (*cb)(int, int, void*), void *arg);
/* Just define some random names for the functions to make them easier to use */
#define sceCtrlSetButtonMasks sceCtrl_driver_7CA723DC
#define sceCtrlGetButtonMask sceCtrl_driver_5E77BC8A
#define sceCtrlRegisterButtonCallback sceCtrl_driver_5C56C779
#ifdef __cplusplus
}
#endif
#endif

55
src/ctrl/sceCtrl.S Normal file
View File

@@ -0,0 +1,55 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceCtrl_0000
IMPORT_START "sceCtrl",0x40010000
#endif
#ifdef F_sceCtrl_0001
IMPORT_FUNC "sceCtrl",0x6A2774F3,sceCtrlSetSamplingCycle
#endif
#ifdef F_sceCtrl_0002
IMPORT_FUNC "sceCtrl",0x02BAAD91,sceCtrlGetSamplingCycle
#endif
#ifdef F_sceCtrl_0003
IMPORT_FUNC "sceCtrl",0x1F4011E6,sceCtrlSetSamplingMode
#endif
#ifdef F_sceCtrl_0004
IMPORT_FUNC "sceCtrl",0xDA6B76A1,sceCtrlGetSamplingMode
#endif
#ifdef F_sceCtrl_0005
IMPORT_FUNC "sceCtrl",0x3A622550,sceCtrlPeekBufferPositive
#endif
#ifdef F_sceCtrl_0006
IMPORT_FUNC "sceCtrl",0xC152080A,sceCtrlPeekBufferNegative
#endif
#ifdef F_sceCtrl_0007
IMPORT_FUNC "sceCtrl",0x1F803938,sceCtrlReadBufferPositive
#endif
#ifdef F_sceCtrl_0008
IMPORT_FUNC "sceCtrl",0x60B81F86,sceCtrlReadBufferNegative
#endif
#ifdef F_sceCtrl_0009
IMPORT_FUNC "sceCtrl",0xB1D0E5CD,sceCtrlPeekLatch
#endif
#ifdef F_sceCtrl_0010
IMPORT_FUNC "sceCtrl",0x0B588501,sceCtrlReadLatch
#endif
#ifdef F_sceCtrl_0011
IMPORT_FUNC "sceCtrl",0x348D99D4,sceCtrl_348D99D4
#endif
#ifdef F_sceCtrl_0012
IMPORT_FUNC "sceCtrl",0xAF5960F3,sceCtrl_AF5960F3
#endif
#ifdef F_sceCtrl_0013
IMPORT_FUNC "sceCtrl",0xA68FD260,sceCtrlClearRapidFire
#endif
#ifdef F_sceCtrl_0014
IMPORT_FUNC "sceCtrl",0x6841BE1A,sceCtrlSetRapidFire
#endif
#ifdef F_sceCtrl_0015
IMPORT_FUNC "sceCtrl",0xA7144800,sceCtrlSetIdleCancelThreshold
#endif
#ifdef F_sceCtrl_0016
IMPORT_FUNC "sceCtrl",0x687660FA,sceCtrlGetIdleCancelThreshold
#endif

85
src/ctrl/sceCtrl_driver.S Normal file
View File

@@ -0,0 +1,85 @@
.set noreorder
#include "pspimport.s"
// Build List
// sceCtrl_driver_0000.o sceCtrl_driver_0001.o sceCtrl_driver_0002.o sceCtrl_driver_0003.o sceCtrl_driver_0004.o sceCtrl_driver_0005.o sceCtrl_driver_0006.o sceCtrl_driver_0007.o sceCtrl_driver_0008.o sceCtrl_driver_0009.o sceCtrl_driver_0010.o sceCtrl_driver_0011.o sceCtrl_driver_0012.o sceCtrl_driver_0013.o sceCtrl_driver_0014.o sceCtrl_driver_0015.o sceCtrl_driver_0016.o sceCtrl_driver_0017.o sceCtrl_driver_0018.o sceCtrl_driver_0019.o sceCtrl_driver_0020.o sceCtrl_driver_0021.o sceCtrl_driver_0022.o sceCtrl_driver_0023.o
#ifdef F_sceCtrl_driver_0000
IMPORT_START "sceCtrl_driver",0x00010000
#endif
#ifdef F_sceCtrl_driver_0001
IMPORT_FUNC "sceCtrl_driver",0x3E65A0EA,sceCtrlInit
#endif
#ifdef F_sceCtrl_driver_0002
IMPORT_FUNC "sceCtrl_driver",0xE03956E9,sceCtrlEnd
#endif
#ifdef F_sceCtrl_driver_0003
IMPORT_FUNC "sceCtrl_driver",0xC3F607F3,sceCtrlSuspend
#endif
#ifdef F_sceCtrl_driver_0004
IMPORT_FUNC "sceCtrl_driver",0xC245B57B,sceCtrlResume
#endif
#ifdef F_sceCtrl_driver_0005
IMPORT_FUNC "sceCtrl_driver",0x6A2774F3,sceCtrlSetSamplingCycle
#endif
#ifdef F_sceCtrl_driver_0006
IMPORT_FUNC "sceCtrl_driver",0x02BAAD91,sceCtrlGetSamplingCycle
#endif
#ifdef F_sceCtrl_driver_0007
IMPORT_FUNC "sceCtrl_driver",0x1F4011E6,sceCtrlSetSamplingMode
#endif
#ifdef F_sceCtrl_driver_0008
IMPORT_FUNC "sceCtrl_driver",0xDA6B76A1,sceCtrlGetSamplingMode
#endif
#ifdef F_sceCtrl_driver_0009
IMPORT_FUNC "sceCtrl_driver",0x3A622550,sceCtrlPeekBufferPositive
#endif
#ifdef F_sceCtrl_driver_0010
IMPORT_FUNC "sceCtrl_driver",0xC152080A,sceCtrlPeekBufferNegative
#endif
#ifdef F_sceCtrl_driver_0011
IMPORT_FUNC "sceCtrl_driver",0x1F803938,sceCtrlReadBufferPositive
#endif
#ifdef F_sceCtrl_driver_0012
IMPORT_FUNC "sceCtrl_driver",0x60B81F86,sceCtrlReadBufferNegative
#endif
#ifdef F_sceCtrl_driver_0013
IMPORT_FUNC "sceCtrl_driver",0xB1D0E5CD,sceCtrlPeekLatch
#endif
#ifdef F_sceCtrl_driver_0014
IMPORT_FUNC "sceCtrl_driver",0x0B588501,sceCtrlReadLatch
#endif
#ifdef F_sceCtrl_driver_0015
IMPORT_FUNC "sceCtrl_driver",0xA88E8D22,sceCtrlSetIdleCancelKey
#endif
#ifdef F_sceCtrl_driver_0016
IMPORT_FUNC "sceCtrl_driver",0xB7CEAED4,sceCtrlGetIdleCancelKey
#endif
#ifdef F_sceCtrl_driver_0017
IMPORT_FUNC "sceCtrl_driver",0x348D99D4,sceCtrl_driver_348D99D4
#endif
#ifdef F_sceCtrl_driver_0018
IMPORT_FUNC "sceCtrl_driver",0xAF5960F3,sceCtrl_driver_AF5960F3
#endif
#ifdef F_sceCtrl_driver_0019
IMPORT_FUNC "sceCtrl_driver",0xA68FD260,sceCtrlClearRapidFire
#endif
#ifdef F_sceCtrl_driver_0020
IMPORT_FUNC "sceCtrl_driver",0x6841BE1A,sceCtrlSetRapidFire
#endif
#ifdef F_sceCtrl_driver_0021
IMPORT_FUNC "sceCtrl_driver",0x7CA723DC,sceCtrl_driver_7CA723DC
#endif
#ifdef F_sceCtrl_driver_0022
IMPORT_FUNC "sceCtrl_driver",0x5E77BC8A,sceCtrl_driver_5E77BC8A
#endif
#ifdef F_sceCtrl_driver_0023
IMPORT_FUNC "sceCtrl_driver",0x5C56C779,sceCtrl_driver_5C56C779
#endif
#ifdef F_sceCtrl_driver_0024
IMPORT_FUNC "sceCtrl_driver",0xA7144800,sceCtrlSetIdleCancelThreshold
#endif
#ifdef F_sceCtrl_driver_0025
IMPORT_FUNC "sceCtrl_driver",0x687660FA,sceCtrlGetIdleCancelThreshold
#endif

50
src/debug/Makefile.am Normal file
View File

@@ -0,0 +1,50 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base \
-I$(top_srcdir)/src/kernel \
-I$(top_srcdir)/src/display \
-I$(top_srcdir)/src/ge \
-I$(top_srcdir)/src/user \
-I$(top_srcdir)/src/ctrl
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) $(INCLUDES)
SCRPRINT_OBJS = pspDebugScreenInit.o pspDebugScreenPrintf.o pspDebugScreenKprintf.o
libpspdebugincludedir = @PSPSDK_INCLUDEDIR@
libpspdebuginclude_HEADERS = \
pspdebug.h pspdebugkb.h
lib_LIBRARIES = libpspdebug.a libpspgdb.a libpspgdb_user.a libpspgdb_kernel.a libpspdebugkb.a
libpspdebug_a_SOURCES = \
callstack.c \
callstackget.S \
font.c \
scr_printf.c \
exception.c \
exception_asm.S \
kprintf.c \
stacktrace.c \
profiler.c \
stdio.c \
sio.c
libpspdebug_a_LIBADD = $(SCRPRINT_OBJS)
libpspgdb_a_SOURCES = gdb-stub.c
libpspgdb_user_a_SOURCES = gdb-userlib.c
libpspgdb_kernel_a_SOURCES = gdb-kernellib.c
libpspdebugkb_a_SOURCES = pspdebugkb.c
$(SCRPRINT_OBJS): scr_printf.c
$(COMPILE) -DF_$* $< -c -o $@

256
src/debug/callstack.c Normal file
View File

@@ -0,0 +1,256 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* callstack.c - Return stack generation for MIPS processors.
*
* Copyright (c) 1992, 1998 The Open Group
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: callstack.c 1492 2005-11-26 23:19:30Z mrbrown $
*/
#include "pspdebug.h"
/*
* $Xorg: getretmips.c,v 1.4 2001/02/09 02:06:19 xorgcvs Exp$
*
Copyright 1992, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* Author: Keith Packard, MIT X Consortium
* cleaned up slighly by emoon and added ee related opcodes and checking.
*/
/* Return stack generation for MIPS processors
* This is tricky as MIPS stack frames aren't
* easily unrolled -- we look for pc restoration
* and stack adjustment instructions beyond the return
* address to discover the correct values
*/
/* lw $31,const($sp) is : 100 011 11101 11111 const */
/* 1000 1111 1011 1111 */
#define RESTORE_RETURNVAL 0x8fbf0000
#define RESTORE_RETURNVAL_MASK 0xffff0000
/* ld $31,const($sp) is : 110 111 11101 11111 const */
/* 1101 1111 1011 1111 */
#define RESTORE_RETURNVAL2 0xdfbf0000
/* lq $31,const($sp) is : 011110 11101 11111 const */
/* ee Related 0111 1011 1011 1111 */
#define RESTORE_RETURNVAL3 0x7bbf0000
/* addiu $sp, $sp, const is 001 001 11101 11101 const */
/* 0010 0111 1011 1101 const */
#define ADJUST_STACKP_C 0x27bd0000
#define ADJUST_STACKP_C_MASK 0xffff0000
/* addu $sp, $sp, $at is 000 000 11101 00001 11101 00000 100 001 */
/* 0000 0011 1010 0001 1110 1000 0010 0001 */
#define ADJUST_STACKP_V 0x03a1e821
#define ADJUST_STACKP_V_MASK 0xffffffff
/* lui $at, const is 001 111 00000 00001 const */
/* 0011 1100 0000 0001 const */
#define SET_UPPER_C 0x3c010000
#define SET_UPPER_C_MASK 0xffff0000
/* ori $at, $at, const is 001 101 00001 00001 const */
/* 0011 0100 0010 0001 const */
#define OR_LOWER_C 0x34210000
#define OR_LOWER_C_MASK 0xffff0000
/* ori $at, $zero, const is 001 101 00000 00001 const */
/* 0011 0100 0000 0001 const */
#define SET_LOWER_C 0x34010000
#define SET_LOWER_C_MASK 0xffff0000
/* jr $ra */
#define RETURN 0x03e00008
#define CALL(f) (0x0c000000 | (((int) (f)) >> 2))
/*
* This computation is expensive, so we cache the results;
* a simple hash function and straight-forward replacement.
*/
#define HASH_SIZE 256
typedef struct _returnCache
{
unsigned int *returnAddress;
int raOffset;
int spAdjust;
} ReturnCacheRec, *ReturnCachePtr;
static ReturnCacheRec returnCache[HASH_SIZE];
#define HASH(ra) ((((int) (ra)) >> 2) & (HASH_SIZE - 1))
typedef int Bool;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
extern unsigned int *pspGetReturnAddress();
extern unsigned int *pspGetStackPointer();
extern int main();
int pspDebugGetStackTrace(unsigned int *results, int max)
{
unsigned int *ra;
unsigned int *ra_limit;
unsigned int *sp;
unsigned int inst;
unsigned int mainCall;
unsigned short const_upper;
unsigned short const_lower;
int ra_offset;
int sp_adjust;
Bool found_ra_offset, found_sp_adjust;
Bool found_const_upper, found_const_lower;
ReturnCachePtr rc;
int total = max;
ra = pspGetReturnAddress();
sp = pspGetStackPointer();
mainCall = CALL(main);
while (ra && max)
{
rc = &returnCache[HASH(ra)];
if (rc->returnAddress != ra)
{
found_ra_offset = FALSE;
found_sp_adjust = FALSE;
found_const_upper = FALSE;
found_const_lower = FALSE;
const_upper = 0;
const_lower = 0;
rc->returnAddress = ra;
ra_limit = (unsigned int *) 0x200000;
ra_offset = 0;
sp_adjust = -1;
while ((!found_ra_offset || !found_sp_adjust) && ra < ra_limit)
{
inst = *ra;
/* look for the offset of the PC in the stack frame */
if ((inst & RESTORE_RETURNVAL_MASK) == RESTORE_RETURNVAL)
{
ra_offset = inst & ~RESTORE_RETURNVAL_MASK;
found_ra_offset = TRUE;
}
else if ((inst & RESTORE_RETURNVAL_MASK) == RESTORE_RETURNVAL2)
{
ra_offset = inst & ~RESTORE_RETURNVAL_MASK;
found_ra_offset = TRUE;
}
else if ((inst & RESTORE_RETURNVAL_MASK) == RESTORE_RETURNVAL3)
{
ra_offset = inst & ~RESTORE_RETURNVAL_MASK;
found_ra_offset = TRUE;
}
else if ((inst & ADJUST_STACKP_C_MASK) == ADJUST_STACKP_C)
{
sp_adjust = inst & ~ADJUST_STACKP_C_MASK;
found_sp_adjust = TRUE;
}
else if ((inst & ADJUST_STACKP_V_MASK) == ADJUST_STACKP_V)
{
sp_adjust = 0;
found_sp_adjust = TRUE;
}
else if ((inst & SET_UPPER_C_MASK) == SET_UPPER_C)
{
const_upper = inst & ~SET_UPPER_C_MASK;
const_lower = 0;
found_const_upper = TRUE;
}
else if ((inst & OR_LOWER_C_MASK) == OR_LOWER_C)
{
const_lower = inst & ~OR_LOWER_C_MASK;
found_const_lower = TRUE;
}
else if ((inst & SET_LOWER_C_MASK) == SET_LOWER_C)
{
const_lower = inst & ~SET_LOWER_C_MASK;
const_upper = 0;
found_const_lower = TRUE;
}
else if (inst == RETURN)
ra_limit = ra + 2;
ra++;
}
if (sp_adjust == 0 && (found_const_upper || found_const_lower))
sp_adjust = (const_upper << 16) | const_lower;
rc->raOffset = ra_offset;
rc->spAdjust = sp_adjust;
}
/* if something went wrong, punt */
if (rc->spAdjust <= 0)
{
*results++ = 0;
break;
}
ra = (unsigned int *) sp[rc->raOffset >> 2];
sp += rc->spAdjust >> 2;
if (ra == 0)
{
*results++ = 0;
break;
}
*results++ = ((unsigned int) ra) - 8;
max--;
if (ra[-2] == mainCall)
{
*results++ = 0;
break;
}
}
return total - max;
}

46
src/debug/callstackget.S Normal file
View File

@@ -0,0 +1,46 @@
/*
* $XConsortium: mipsstack.s,v 1.3 94/04/17 20:59:45 keith Exp $
*
Copyright (c) 1992 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.
*
* Author: Keith Packard, MIT X Consortium
*/
.globl pspGetReturnAddress
.ent pspGetReturnAddress
pspGetReturnAddress:
.frame $sp, 0, $31
move $2,$31
j $31
.end pspGetReturnAddress
.globl pspGetStackPointer
.ent pspGetStackPointer
pspGetStackPointer:
.frame $sp, 0, $31
move $2,$29
j $31
.end pspGetStackPointer

103
src/debug/exception.c Normal file
View File

@@ -0,0 +1,103 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspexception.c - Basic exception handler for applications.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: exception.c 1777 2006-02-01 22:23:22Z tyranid $
*/
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
static PspDebugErrorHandler curr_handler = NULL;
void _pspDebugExceptionHandler(void);
PspDebugRegBlock _pspDebugExceptRegs;
int sceKernelRegisterDefaultExceptionHandler(void *func);
/* Install an error handler */
int pspDebugInstallErrorHandler(PspDebugErrorHandler handler)
{
u32 addr;
curr_handler = handler;
addr = (u32) _pspDebugExceptionHandler;
addr |= 0x80000000;
return sceKernelRegisterDefaultExceptionHandler((void *) addr);
}
/* Mnemonic register names */
static const unsigned char regName[32][5] =
{
"zr", "at", "v0", "v1", "a0", "a1", "a2", "a3",
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
"t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
};
/* Taken from the ps2, might not be 100% correct */
static const char *codeTxt[32] =
{
"Interrupt", "TLB modification", "TLB load/inst fetch", "TLB store",
"Address load/inst fetch", "Address store", "Bus error (instr)",
"Bus error (data)", "Syscall", "Breakpoint", "Reserved instruction",
"Coprocessor unusable", "Arithmetic overflow", "Unknown 13", "Unknown 14",
"FPU Exception", "Unknown 16", "Unknown 17", "Unknown 18",
"Unknown 20", "Unknown 21", "Unknown 22", "Unknown 23",
"Unknown 24", "Unknown 25", "Unknown 26", "Unknown 27",
"Unknown 28", "Unknown 29", "Unknown 30", "Unknown 31"
};
/* Dump an exception to screen */
void pspDebugDumpException(PspDebugRegBlock *regs)
{
int i;
pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]);
pspDebugScreenPrintf("EPC - %08X\n", regs->epc);
pspDebugScreenPrintf("Cause - %08X\n", regs->cause);
pspDebugScreenPrintf("Status - %08X\n", regs->status);
pspDebugScreenPrintf("BadVAddr - %08X\n", regs->badvaddr);
for(i = 0; i < 32; i+=4)
{
pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], regs->r[i],
regName[i+1], regs->r[i+1], regName[i+2], regs->r[i+2], regName[i+3], regs->r[i+3]);
}
sceDisplayWaitVblankStart();
}
/* Our default handler in case nothing else is installed */
static void _pspDebugDefaultHandler(PspDebugRegBlock *regs)
{
pspDebugScreenInit();
pspDebugDumpException(regs);
}
/**
* The entry point for our exception "trap"
*/
void _pspDebugTrapEntry(void)
{
/* No special stack is used here, if the thread's stack is trashed we might be in trouble */
if(curr_handler != NULL)
{
curr_handler(&_pspDebugExceptRegs);
}
else
{
_pspDebugDefaultHandler(&_pspDebugExceptRegs);
}
/* Kill this thread as we cannot necessarily continue */
/* Technically you might be able to "restart" after something like a break */
sceKernelExitDeleteThread(0);
}

334
src/debug/exception_asm.S Normal file
View File

@@ -0,0 +1,334 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspexception_asm.S - Basic exception handler for applications.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id$
*/
#include "as_reg_compat.h"
.set noreorder
.set noat
#define BadVAddr $8 // Address for the most recent address-related exception
#define Status $12 // Processor status and control
#define Cause $13 // Cause of last general exception
#define EPC $14 // Program counter at last exception
#define PRId $15 // Processor identification and revision
#define FSR $31
#define FIR $0
#define REG_GPR_0 (6*4)
#define REG_GPR_1 (REG_GPR_0 + 4)
#define REG_GPR_2 (REG_GPR_1 + 4)
#define REG_GPR_3 (REG_GPR_2 + 4)
#define REG_GPR_4 (REG_GPR_3 + 4)
#define REG_GPR_5 (REG_GPR_4 + 4)
#define REG_GPR_6 (REG_GPR_5 + 4)
#define REG_GPR_7 (REG_GPR_6 + 4)
#define REG_GPR_8 (REG_GPR_7 + 4)
#define REG_GPR_9 (REG_GPR_8 + 4)
#define REG_GPR_10 (REG_GPR_9 + 4)
#define REG_GPR_11 (REG_GPR_10 + 4)
#define REG_GPR_12 (REG_GPR_11 + 4)
#define REG_GPR_13 (REG_GPR_12 + 4)
#define REG_GPR_14 (REG_GPR_13 + 4)
#define REG_GPR_15 (REG_GPR_14 + 4)
#define REG_GPR_16 (REG_GPR_15 + 4)
#define REG_GPR_17 (REG_GPR_16 + 4)
#define REG_GPR_18 (REG_GPR_17 + 4)
#define REG_GPR_19 (REG_GPR_18 + 4)
#define REG_GPR_20 (REG_GPR_19 + 4)
#define REG_GPR_21 (REG_GPR_20 + 4)
#define REG_GPR_22 (REG_GPR_21 + 4)
#define REG_GPR_23 (REG_GPR_22 + 4)
#define REG_GPR_24 (REG_GPR_23 + 4)
#define REG_GPR_25 (REG_GPR_24 + 4)
#define REG_GPR_26 (REG_GPR_25 + 4)
#define REG_GPR_27 (REG_GPR_26 + 4)
#define REG_GPR_28 (REG_GPR_27 + 4)
#define REG_GPR_29 (REG_GPR_28 + 4)
#define REG_GPR_30 (REG_GPR_29 + 4)
#define REG_GPR_31 (REG_GPR_30 + 4)
#define REG_STATUS (REG_GPR_31 + 4)
#define REG_LO (REG_STATUS + 4)
#define REG_HI (REG_LO + 4)
#define REG_BADVADDR (REG_HI + 4)
#define REG_CAUSE (REG_BADVADDR + 4)
#define REG_EPC (REG_CAUSE + 4)
#define REG_FPR_0 (REG_EPC + 4)
#define REG_FPR_1 (REG_FPR_0 + 4)
#define REG_FPR_2 (REG_FPR_1 + 4)
#define REG_FPR_3 (REG_FPR_2 + 4)
#define REG_FPR_4 (REG_FPR_3 + 4)
#define REG_FPR_5 (REG_FPR_4 + 4)
#define REG_FPR_6 (REG_FPR_5 + 4)
#define REG_FPR_7 (REG_FPR_6 + 4)
#define REG_FPR_8 (REG_FPR_7 + 4)
#define REG_FPR_9 (REG_FPR_8 + 4)
#define REG_FPR_10 (REG_FPR_9 + 4)
#define REG_FPR_11 (REG_FPR_10 + 4)
#define REG_FPR_12 (REG_FPR_11 + 4)
#define REG_FPR_13 (REG_FPR_12 + 4)
#define REG_FPR_14 (REG_FPR_13 + 4)
#define REG_FPR_15 (REG_FPR_14 + 4)
#define REG_FPR_16 (REG_FPR_15 + 4)
#define REG_FPR_17 (REG_FPR_16 + 4)
#define REG_FPR_18 (REG_FPR_17 + 4)
#define REG_FPR_19 (REG_FPR_18 + 4)
#define REG_FPR_20 (REG_FPR_19 + 4)
#define REG_FPR_21 (REG_FPR_20 + 4)
#define REG_FPR_22 (REG_FPR_21 + 4)
#define REG_FPR_23 (REG_FPR_22 + 4)
#define REG_FPR_24 (REG_FPR_23 + 4)
#define REG_FPR_25 (REG_FPR_24 + 4)
#define REG_FPR_26 (REG_FPR_25 + 4)
#define REG_FPR_27 (REG_FPR_26 + 4)
#define REG_FPR_28 (REG_FPR_27 + 4)
#define REG_FPR_29 (REG_FPR_28 + 4)
#define REG_FPR_30 (REG_FPR_29 + 4)
#define REG_FPR_31 (REG_FPR_30 + 4)
#define REG_FSR (REG_FPR_31 + 4)
#define REG_FIR (REG_FSR + 4)
#define REG_FP (REG_FIR + 4)
.extern _pspDebugExceptRegs
.extern _pspDebugTrapEntry
.global pspDebugResumeFromException
.ent pspDebugResumeFromException
pspDebugResumeFromException:
break
.end pspDebugResumeFromException
.global _pspDebugExceptionHandler
.ent _pspDebugExceptionHandler
_pspDebugExceptionHandler:
nop
nop
la $v1, pspDebugResumeFromException
mfc0 $v0, EPC
beq $v0, $v1, _pspDebugExceptionResume
nop
la $v0, _pspDebugExceptRegs
sw $0, REG_GPR_0($v0)
sw $1, REG_GPR_1($v0)
cfc0 $1, $4 # Get original v0
sw $1, REG_GPR_2($v0)
cfc0 $1, $5 # Get original v1
sw $1, REG_GPR_3($v0)
sw $4, REG_GPR_4($v0)
sw $5, REG_GPR_5($v0)
sw $6, REG_GPR_6($v0)
sw $7, REG_GPR_7($v0)
sw $8, REG_GPR_8($v0)
sw $9, REG_GPR_9($v0)
sw $10, REG_GPR_10($v0)
sw $11, REG_GPR_11($v0)
sw $12, REG_GPR_12($v0)
sw $13, REG_GPR_13($v0)
sw $14, REG_GPR_14($v0)
sw $15, REG_GPR_15($v0)
sw $16, REG_GPR_16($v0)
sw $17, REG_GPR_17($v0)
sw $18, REG_GPR_18($v0)
sw $19, REG_GPR_19($v0)
sw $20, REG_GPR_20($v0)
sw $21, REG_GPR_21($v0)
sw $22, REG_GPR_22($v0)
sw $23, REG_GPR_23($v0)
sw $24, REG_GPR_24($v0)
sw $25, REG_GPR_25($v0)
sw $26, REG_GPR_26($v0)
sw $27, REG_GPR_27($v0)
sw $28, REG_GPR_28($v0)
sw $29, REG_GPR_29($v0)
sw $30, REG_GPR_30($v0)
sw $31, REG_GPR_31($v0)
mflo $v1
sw $v1, REG_LO($v0)
mfhi $v1
sw $v1, REG_HI($v0)
mfc0 $v1, BadVAddr
sw $v1, REG_BADVADDR($v0)
mfc0 $v1, Cause
sw $v1, REG_CAUSE($v0)
mfc0 $v1, EPC
sw $v1, REG_EPC($v0)
mfc0 $v1, Status
sw $v1, REG_STATUS($v0)
# Check if cop1 is enable and skip if not
lui $a0, 0x2000
and $a0, $a0, $v1
beq $a0, $0, 1f
nop
swc1 $0, REG_FPR_0($v0)
swc1 $1, REG_FPR_1($v0)
swc1 $2, REG_FPR_2($v0)
swc1 $3, REG_FPR_3($v0)
swc1 $4, REG_FPR_4($v0)
swc1 $5, REG_FPR_5($v0)
swc1 $6, REG_FPR_6($v0)
swc1 $7, REG_FPR_7($v0)
swc1 $8, REG_FPR_8($v0)
swc1 $9, REG_FPR_9($v0)
swc1 $10, REG_FPR_10($v0)
swc1 $11, REG_FPR_11($v0)
swc1 $12, REG_FPR_12($v0)
swc1 $13, REG_FPR_13($v0)
swc1 $14, REG_FPR_14($v0)
swc1 $15, REG_FPR_15($v0)
swc1 $16, REG_FPR_16($v0)
swc1 $17, REG_FPR_17($v0)
swc1 $18, REG_FPR_18($v0)
swc1 $19, REG_FPR_19($v0)
swc1 $20, REG_FPR_20($v0)
swc1 $21, REG_FPR_21($v0)
swc1 $22, REG_FPR_22($v0)
swc1 $23, REG_FPR_23($v0)
swc1 $24, REG_FPR_24($v0)
swc1 $25, REG_FPR_25($v0)
swc1 $26, REG_FPR_26($v0)
swc1 $27, REG_FPR_27($v0)
swc1 $28, REG_FPR_28($v0)
swc1 $29, REG_FPR_29($v0)
swc1 $30, REG_FPR_30($v0)
swc1 $31, REG_FPR_31($v0)
cfc1 $t0, FSR
sw $t0, REG_FSR($v0)
cfc1 $t0, FIR
sw $t0, REG_FIR($v0)
ctc1 $0, FSR # Clear any cause flags
# Jump target for ignore cop1
1:
sw $sp, REG_FP($v0)
la $2, _pspDebugTrapEntry
mtc0 $2, $14
nop
nop
eret
nop
nop
.end _pspDebugExceptionHandler
.ent _pspDebugExceptionResume
_pspDebugExceptionResume:
# Resume from the exception in user mode (possibly, could be kernel but we don't really know that)
la $v0, _pspDebugExceptRegs
lw $v1, REG_STATUS($v0)
# Check if cop1 is enable and skip if not
lui $a0, 0x2000
and $a0, $a0, $v1
beq $a0, $0, 1f
nop
lwc1 $0, REG_FPR_0($v0)
lwc1 $1, REG_FPR_1($v0)
lwc1 $2, REG_FPR_2($v0)
lwc1 $3, REG_FPR_3($v0)
lwc1 $4, REG_FPR_4($v0)
lwc1 $5, REG_FPR_5($v0)
lwc1 $6, REG_FPR_6($v0)
lwc1 $7, REG_FPR_7($v0)
lwc1 $8, REG_FPR_8($v0)
lwc1 $9, REG_FPR_9($v0)
lwc1 $10, REG_FPR_10($v0)
lwc1 $11, REG_FPR_11($v0)
lwc1 $12, REG_FPR_12($v0)
lwc1 $13, REG_FPR_13($v0)
lwc1 $14, REG_FPR_14($v0)
lwc1 $15, REG_FPR_15($v0)
lwc1 $16, REG_FPR_16($v0)
lwc1 $17, REG_FPR_17($v0)
lwc1 $18, REG_FPR_18($v0)
lwc1 $19, REG_FPR_19($v0)
lwc1 $20, REG_FPR_20($v0)
lwc1 $21, REG_FPR_21($v0)
lwc1 $22, REG_FPR_22($v0)
lwc1 $23, REG_FPR_23($v0)
lwc1 $24, REG_FPR_24($v0)
lwc1 $25, REG_FPR_25($v0)
lwc1 $26, REG_FPR_26($v0)
lwc1 $27, REG_FPR_27($v0)
lwc1 $28, REG_FPR_28($v0)
lwc1 $29, REG_FPR_29($v0)
lwc1 $30, REG_FPR_30($v0)
lwc1 $31, REG_FPR_31($v0)
lw $t0, REG_FSR($v0)
li $t1, 0xFFFC0F83
and $t0, $t0, $t1 # Clear the cause and flags before ret
ctc1 $t0, FSR
1:
# lw $0, REG_GPR_0($v0)
# lw $1, REG_GPR_1($v0)
# Don't do 2 yet
lw $3, REG_GPR_3($v0)
lw $4, REG_GPR_4($v0)
lw $5, REG_GPR_5($v0)
lw $6, REG_GPR_6($v0)
lw $7, REG_GPR_7($v0)
lw $8, REG_GPR_8($v0)
lw $9, REG_GPR_9($v0)
lw $10, REG_GPR_10($v0)
lw $11, REG_GPR_11($v0)
lw $12, REG_GPR_12($v0)
lw $13, REG_GPR_13($v0)
lw $14, REG_GPR_14($v0)
lw $15, REG_GPR_15($v0)
lw $16, REG_GPR_16($v0)
lw $17, REG_GPR_17($v0)
lw $18, REG_GPR_18($v0)
lw $19, REG_GPR_19($v0)
lw $20, REG_GPR_20($v0)
lw $21, REG_GPR_21($v0)
lw $22, REG_GPR_22($v0)
lw $23, REG_GPR_23($v0)
lw $24, REG_GPR_24($v0)
lw $25, REG_GPR_25($v0)
lw $26, REG_GPR_26($v0)
lw $27, REG_GPR_27($v0)
lw $28, REG_GPR_28($v0)
lw $29, REG_GPR_29($v0)
lw $30, REG_GPR_30($v0)
lw $31, REG_GPR_31($v0)
lw $1, REG_EPC($v0)
mtc0 $1, EPC
# Restore 1 + 2 now
lw $1, REG_GPR_1($v0)
lw $2, REG_GPR_2($v0)
nop
nop
eret
.end _pspDebugExceptionResume

147
src/debug/font.c Normal file
View File

@@ -0,0 +1,147 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* font.c - Debug Font.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: font.c 540 2005-07-08 19:35:10Z warren $
*/
#include <psptypes.h>
u8 msx[]=
"\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x42\xa5\x81\xa5\x99\x42\x3c"
"\x3c\x7e\xdb\xff\xff\xdb\x66\x3c\x6c\xfe\xfe\xfe\x7c\x38\x10\x00"
"\x10\x38\x7c\xfe\x7c\x38\x10\x00\x10\x38\x54\xfe\x54\x10\x38\x00"
"\x10\x38\x7c\xfe\xfe\x10\x38\x00\x00\x00\x00\x30\x30\x00\x00\x00"
"\xff\xff\xff\xe7\xe7\xff\xff\xff\x38\x44\x82\x82\x82\x44\x38\x00"
"\xc7\xbb\x7d\x7d\x7d\xbb\xc7\xff\x0f\x03\x05\x79\x88\x88\x88\x70"
"\x38\x44\x44\x44\x38\x10\x7c\x10\x30\x28\x24\x24\x28\x20\xe0\xc0"
"\x3c\x24\x3c\x24\x24\xe4\xdc\x18\x10\x54\x38\xee\x38\x54\x10\x00"
"\x10\x10\x10\x7c\x10\x10\x10\x10\x10\x10\x10\xff\x00\x00\x00\x00"
"\x00\x00\x00\xff\x10\x10\x10\x10\x10\x10\x10\xf0\x10\x10\x10\x10"
"\x10\x10\x10\x1f\x10\x10\x10\x10\x10\x10\x10\xff\x10\x10\x10\x10"
"\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00\xff\x00\x00\x00\x00"
"\x00\x00\x00\x1f\x10\x10\x10\x10\x00\x00\x00\xf0\x10\x10\x10\x10"
"\x10\x10\x10\x1f\x00\x00\x00\x00\x10\x10\x10\xf0\x00\x00\x00\x00"
"\x81\x42\x24\x18\x18\x24\x42\x81\x01\x02\x04\x08\x10\x20\x40\x80"
"\x80\x40\x20\x10\x08\x04\x02\x01\x00\x10\x10\xff\x10\x10\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x00\x00\x20\x00"
"\x50\x50\x50\x00\x00\x00\x00\x00\x50\x50\xf8\x50\xf8\x50\x50\x00"
"\x20\x78\xa0\x70\x28\xf0\x20\x00\xc0\xc8\x10\x20\x40\x98\x18\x00"
"\x40\xa0\x40\xa8\x90\x98\x60\x00\x10\x20\x40\x00\x00\x00\x00\x00"
"\x10\x20\x40\x40\x40\x20\x10\x00\x40\x20\x10\x10\x10\x20\x40\x00"
"\x20\xa8\x70\x20\x70\xa8\x20\x00\x00\x20\x20\xf8\x20\x20\x00\x00"
"\x00\x00\x00\x00\x00\x20\x20\x40\x00\x00\x00\x78\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x60\x60\x00\x00\x00\x08\x10\x20\x40\x80\x00"
"\x70\x88\x98\xa8\xc8\x88\x70\x00\x20\x60\xa0\x20\x20\x20\xf8\x00"
"\x70\x88\x08\x10\x60\x80\xf8\x00\x70\x88\x08\x30\x08\x88\x70\x00"
"\x10\x30\x50\x90\xf8\x10\x10\x00\xf8\x80\xe0\x10\x08\x10\xe0\x00"
"\x30\x40\x80\xf0\x88\x88\x70\x00\xf8\x88\x10\x20\x20\x20\x20\x00"
"\x70\x88\x88\x70\x88\x88\x70\x00\x70\x88\x88\x78\x08\x10\x60\x00"
"\x00\x00\x20\x00\x00\x20\x00\x00\x00\x00\x20\x00\x00\x20\x20\x40"
"\x18\x30\x60\xc0\x60\x30\x18\x00\x00\x00\xf8\x00\xf8\x00\x00\x00"
"\xc0\x60\x30\x18\x30\x60\xc0\x00\x70\x88\x08\x10\x20\x00\x20\x00"
"\x70\x88\x08\x68\xa8\xa8\x70\x00\x20\x50\x88\x88\xf8\x88\x88\x00"
"\xf0\x48\x48\x70\x48\x48\xf0\x00\x30\x48\x80\x80\x80\x48\x30\x00"
"\xe0\x50\x48\x48\x48\x50\xe0\x00\xf8\x80\x80\xf0\x80\x80\xf8\x00"
"\xf8\x80\x80\xf0\x80\x80\x80\x00\x70\x88\x80\xb8\x88\x88\x70\x00"
"\x88\x88\x88\xf8\x88\x88\x88\x00\x70\x20\x20\x20\x20\x20\x70\x00"
"\x38\x10\x10\x10\x90\x90\x60\x00\x88\x90\xa0\xc0\xa0\x90\x88\x00"
"\x80\x80\x80\x80\x80\x80\xf8\x00\x88\xd8\xa8\xa8\x88\x88\x88\x00"
"\x88\xc8\xc8\xa8\x98\x98\x88\x00\x70\x88\x88\x88\x88\x88\x70\x00"
"\xf0\x88\x88\xf0\x80\x80\x80\x00\x70\x88\x88\x88\xa8\x90\x68\x00"
"\xf0\x88\x88\xf0\xa0\x90\x88\x00\x70\x88\x80\x70\x08\x88\x70\x00"
"\xf8\x20\x20\x20\x20\x20\x20\x00\x88\x88\x88\x88\x88\x88\x70\x00"
"\x88\x88\x88\x88\x50\x50\x20\x00\x88\x88\x88\xa8\xa8\xd8\x88\x00"
"\x88\x88\x50\x20\x50\x88\x88\x00\x88\x88\x88\x70\x20\x20\x20\x00"
"\xf8\x08\x10\x20\x40\x80\xf8\x00\x70\x40\x40\x40\x40\x40\x70\x00"
"\x00\x00\x80\x40\x20\x10\x08\x00\x70\x10\x10\x10\x10\x10\x70\x00"
"\x20\x50\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00"
"\x40\x20\x10\x00\x00\x00\x00\x00\x00\x00\x70\x08\x78\x88\x78\x00"
"\x80\x80\xb0\xc8\x88\xc8\xb0\x00\x00\x00\x70\x88\x80\x88\x70\x00"
"\x08\x08\x68\x98\x88\x98\x68\x00\x00\x00\x70\x88\xf8\x80\x70\x00"
"\x10\x28\x20\xf8\x20\x20\x20\x00\x00\x00\x68\x98\x98\x68\x08\x70"
"\x80\x80\xf0\x88\x88\x88\x88\x00\x20\x00\x60\x20\x20\x20\x70\x00"
"\x10\x00\x30\x10\x10\x10\x90\x60\x40\x40\x48\x50\x60\x50\x48\x00"
"\x60\x20\x20\x20\x20\x20\x70\x00\x00\x00\xd0\xa8\xa8\xa8\xa8\x00"
"\x00\x00\xb0\xc8\x88\x88\x88\x00\x00\x00\x70\x88\x88\x88\x70\x00"
"\x00\x00\xb0\xc8\xc8\xb0\x80\x80\x00\x00\x68\x98\x98\x68\x08\x08"
"\x00\x00\xb0\xc8\x80\x80\x80\x00\x00\x00\x78\x80\xf0\x08\xf0\x00"
"\x40\x40\xf0\x40\x40\x48\x30\x00\x00\x00\x90\x90\x90\x90\x68\x00"
"\x00\x00\x88\x88\x88\x50\x20\x00\x00\x00\x88\xa8\xa8\xa8\x50\x00"
"\x00\x00\x88\x50\x20\x50\x88\x00\x00\x00\x88\x88\x98\x68\x08\x70"
"\x00\x00\xf8\x10\x20\x40\xf8\x00\x18\x20\x20\x40\x20\x20\x18\x00"
"\x20\x20\x20\x00\x20\x20\x20\x00\xc0\x20\x20\x10\x20\x20\xc0\x00"
"\x40\xa8\x10\x00\x00\x00\x00\x00\x00\x00\x20\x50\xf8\x00\x00\x00"
"\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00"
"\x10\x20\x70\x88\xf8\x80\x70\x00\x20\x50\x70\x08\x78\x88\x78\x00"
"\x48\x00\x70\x08\x78\x88\x78\x00\x20\x10\x70\x08\x78\x88\x78\x00"
"\x20\x00\x70\x08\x78\x88\x78\x00\x00\x70\x80\x80\x80\x70\x10\x60"
"\x20\x50\x70\x88\xf8\x80\x70\x00\x50\x00\x70\x88\xf8\x80\x70\x00"
"\x20\x10\x70\x88\xf8\x80\x70\x00\x50\x00\x00\x60\x20\x20\x70\x00"
"\x20\x50\x00\x60\x20\x20\x70\x00\x40\x20\x00\x60\x20\x20\x70\x00"
"\x50\x00\x20\x50\x88\xf8\x88\x00\x20\x00\x20\x50\x88\xf8\x88\x00"
"\x10\x20\xf8\x80\xf0\x80\xf8\x00\x00\x00\x6c\x12\x7e\x90\x6e\x00"
"\x3e\x50\x90\x9c\xf0\x90\x9e\x00\x60\x90\x00\x60\x90\x90\x60\x00"
"\x90\x00\x00\x60\x90\x90\x60\x00\x40\x20\x00\x60\x90\x90\x60\x00"
"\x40\xa0\x00\xa0\xa0\xa0\x50\x00\x40\x20\x00\xa0\xa0\xa0\x50\x00"
"\x90\x00\x90\x90\xb0\x50\x10\xe0\x50\x00\x70\x88\x88\x88\x70\x00"
"\x50\x00\x88\x88\x88\x88\x70\x00\x20\x20\x78\x80\x80\x78\x20\x20"
"\x18\x24\x20\xf8\x20\xe2\x5c\x00\x88\x50\x20\xf8\x20\xf8\x20\x00"
"\xc0\xa0\xa0\xc8\x9c\x88\x88\x8c\x18\x20\x20\xf8\x20\x20\x20\x40"
"\x10\x20\x70\x08\x78\x88\x78\x00\x10\x20\x00\x60\x20\x20\x70\x00"
"\x20\x40\x00\x60\x90\x90\x60\x00\x20\x40\x00\x90\x90\x90\x68\x00"
"\x50\xa0\x00\xa0\xd0\x90\x90\x00\x28\x50\x00\xc8\xa8\x98\x88\x00"
"\x00\x70\x08\x78\x88\x78\x00\xf8\x00\x60\x90\x90\x90\x60\x00\xf0"
"\x20\x00\x20\x40\x80\x88\x70\x00\x00\x00\x00\xf8\x80\x80\x00\x00"
"\x00\x00\x00\xf8\x08\x08\x00\x00\x84\x88\x90\xa8\x54\x84\x08\x1c"
"\x84\x88\x90\xa8\x58\xa8\x3c\x08\x20\x00\x00\x20\x20\x20\x20\x00"
"\x00\x00\x24\x48\x90\x48\x24\x00\x00\x00\x90\x48\x24\x48\x90\x00"
"\x28\x50\x20\x50\x88\xf8\x88\x00\x28\x50\x70\x08\x78\x88\x78\x00"
"\x28\x50\x00\x70\x20\x20\x70\x00\x28\x50\x00\x20\x20\x20\x70\x00"
"\x28\x50\x00\x70\x88\x88\x70\x00\x50\xa0\x00\x60\x90\x90\x60\x00"
"\x28\x50\x00\x88\x88\x88\x70\x00\x50\xa0\x00\xa0\xa0\xa0\x50\x00"
"\xfc\x48\x48\x48\xe8\x08\x50\x20\x00\x50\x00\x50\x50\x50\x10\x20"
"\xc0\x44\xc8\x54\xec\x54\x9e\x04\x10\xa8\x40\x00\x00\x00\x00\x00"
"\x00\x20\x50\x88\x50\x20\x00\x00\x88\x10\x20\x40\x80\x28\x00\x00"
"\x7c\xa8\xa8\x68\x28\x28\x28\x00\x38\x40\x30\x48\x48\x30\x08\x70"
"\x00\x00\x00\x00\x00\x00\xff\xff\xf0\xf0\xf0\xf0\x0f\x0f\x0f\x0f"
"\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x3c\x3c\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00"
"\xc0\xc0\xc0\xc0\xc0\xc0\xc0\xc0\x0f\x0f\x0f\x0f\xf0\xf0\xf0\xf0"
"\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\x03\x03\x03\x03\x03\x03\x03\x03"
"\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x11\x22\x44\x88\x11\x22\x44\x88"
"\x88\x44\x22\x11\x88\x44\x22\x11\xfe\x7c\x38\x10\x00\x00\x00\x00"
"\x00\x00\x00\x00\x10\x38\x7c\xfe\x80\xc0\xe0\xf0\xe0\xc0\x80\x00"
"\x01\x03\x07\x0f\x07\x03\x01\x00\xff\x7e\x3c\x18\x18\x3c\x7e\xff"
"\x81\xc3\xe7\xff\xff\xe7\xc3\x81\xf0\xf0\xf0\xf0\x00\x00\x00\x00"
"\x00\x00\x00\x00\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x00\x00\x00\x00"
"\x00\x00\x00\x00\xf0\xf0\xf0\xf0\x33\x33\xcc\xcc\x33\x33\xcc\xcc"
"\x00\x20\x20\x50\x50\x88\xf8\x00\x20\x20\x70\x20\x70\x20\x20\x00"
"\x00\x00\x00\x50\x88\xa8\x50\x00\xff\xff\xff\xff\xff\xff\xff\xff"
"\x00\x00\x00\x00\xff\xff\xff\xff\xf0\xf0\xf0\xf0\xf0\xf0\xf0\xf0"
"\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\xff\xff\xff\xff\x00\x00\x00\x00"
"\x00\x00\x68\x90\x90\x90\x68\x00\x30\x48\x48\x70\x48\x48\x70\xc0"
"\xf8\x88\x80\x80\x80\x80\x80\x00\xf8\x50\x50\x50\x50\x50\x98\x00"
"\xf8\x88\x40\x20\x40\x88\xf8\x00\x00\x00\x78\x90\x90\x90\x60\x00"
"\x00\x50\x50\x50\x50\x68\x80\x80\x00\x50\xa0\x20\x20\x20\x20\x00"
"\xf8\x20\x70\xa8\xa8\x70\x20\xf8\x20\x50\x88\xf8\x88\x50\x20\x00"
"\x70\x88\x88\x88\x50\x50\xd8\x00\x30\x40\x40\x20\x50\x50\x50\x20"
"\x00\x00\x00\x50\xa8\xa8\x50\x00\x08\x70\xa8\xa8\xa8\x70\x80\x00"
"\x38\x40\x80\xf8\x80\x40\x38\x00\x70\x88\x88\x88\x88\x88\x88\x00"
"\x00\xf8\x00\xf8\x00\xf8\x00\x00\x20\x20\xf8\x20\x20\x00\xf8\x00"
"\xc0\x30\x08\x30\xc0\x00\xf8\x00\x18\x60\x80\x60\x18\x00\xf8\x00"
"\x10\x28\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xa0\x40"
"\x00\x20\x00\xf8\x00\x20\x00\x00\x00\x50\xa0\x00\x50\xa0\x00\x00"
"\x00\x18\x24\x24\x18\x00\x00\x00\x00\x30\x78\x78\x30\x00\x00\x00"
"\x00\x00\x00\x00\x30\x00\x00\x00\x3e\x20\x20\x20\xa0\x60\x20\x00"
"\xa0\x50\x50\x50\x00\x00\x00\x00\x40\xa0\x20\x40\xe0\x00\x00\x00"
"\x00\x38\x38\x38\x38\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00";

91
src/debug/gdb-kernellib.c Normal file
View File

@@ -0,0 +1,91 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* gdb-kernellib.c - GDB support functions for kernel mode.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: gdb-kernellib.c 1492 2005-11-26 23:19:30Z mrbrown $
*/
#include <pspkernel.h>
#include <pspdebug.h>
/* GDB Debug putchar */
void putDebugChar(char ch)
{
pspDebugSioPutchar(ch);
}
/* GDB Debug getchar */
char getDebugChar(void)
{
int ch = 0;
while(1)
{
ch = pspDebugSioGetchar();
if(ch != -1)
{
break;
}
}
return ch;
}
void sceKernelDcacheWBinvAll(void);
void sceKernelIcacheClearAll(void);
void _gdbSupportLibFlushCaches(void)
{
pspKernelSetKernelPC();
sceKernelDcacheWBinvAll();
sceKernelIcacheClearAll();
}
int _gdbSupportLibReadByte(unsigned char *address, unsigned char *dest)
{
u32 addr;
addr = (u32) address;
if((addr >= 0x08400000) && (addr < 0x0a000000))
{
*dest = *address;
return 1;
}
else if((addr >= 0x88000000) && (addr < 0x8a000000))
{
*dest = *address;
return 1;
}
return 0;
}
int _gdbSupportLibWriteByte(char val, unsigned char *dest)
{
u32 addr;
addr = (u32) dest;
if((addr >= 0x08400000) && (addr < 0x0a000000))
{
*dest = val;
return 1;
}
else if((addr >= 0x88000000) && (addr < 0x8a000000))
{
*dest = val;
return 1;
}
return 0;
}
int _gdbSupportLibInit(void)
{
/* Do nothing */
return 0;
}

822
src/debug/gdb-stub.c Normal file
View File

@@ -0,0 +1,822 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* gdb-stub.c - Simple remote GDB stub for the psp.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: gdb-stub.c 1152 2005-10-16 20:37:00Z tyranid $
*/
/* Note: there is the odd small bit which comes from the gdb stubs/linux mips stub */
/* As far as I am aware they didn't have an explicit license on them so... */
#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#include <signal.h>
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINTF(fmt, ...) pspDebugScreenPrintf(fmt, ## __VA_ARGS__)
#else
#define DEBUG_PRINTF(fmt, ...)
#endif
/*
* breakpoint and test functions
*/
void pspDebugBreakpoint(void);
void putDebugChar(char ch);
char getDebugChar(void);
int _gdbSupportLibWriteByte(char val, unsigned char *dest);
int _gdbSupportLibReadByte(unsigned char *address, unsigned char *dest);
//void _pspDebugExceptionResume(void);
void pspDebugResumeFromException(void);
void _gdbSupportLibFlushCaches(void);
extern u32 _pspDebugResumePatch;
extern int sceKernelSuspendIntr(void);
extern void sceKernelResumeIntr(int intr);
static void handle_exception(PspDebugRegBlock *regs);
#define MAX_BUF 2048
void _GdbExceptionHandler(void);
static PspDebugRegBlock *_GdbExceptRegs;
static int initialised = 0;
static char input[MAX_BUF];
static char output[MAX_BUF];
static const char hexchars[]="0123456789abcdef";
static char last_cmd = 0;
static int attached = 0;
/* Define a software breakpoint structure */
struct sw_breakpoint
{
unsigned int addr;
unsigned int oldinst;
unsigned int active;
};
static struct sw_breakpoint g_stepbp[2];
/*
* send the packet in buffer.
*/
static void putpacket(unsigned char *buffer)
{
unsigned char checksum;
int count;
unsigned char ch;
/*
* $<packet info>#<checksum>.
*/
do {
putDebugChar('$');
checksum = 0;
count = 0;
while ((ch = buffer[count]) != 0) {
checksum += ch;
count += 1;
putDebugChar(ch);
}
putDebugChar('#');
putDebugChar(hexchars[(checksum >> 4) & 0xf]);
putDebugChar(hexchars[checksum & 0xf]);
DEBUG_PRINTF("calculated checksum = %02X\n", checksum);
}
while ((getDebugChar() & 0x7f) != '+');
}
static char get_char(void)
{
int ch;
while((ch = pspDebugSioGetchar()) == -1);
return ch;
}
/*
* send the packet in buffer.
*/
static int stdout_handler(const char *data, int len)
{
unsigned char checksum;
int count;
unsigned char ch;
if(!attached)
{
return 0;
}
/*
* $<packet info>#<checksum>.
*/
do {
pspDebugSioPutchar('$');
pspDebugSioPutchar('O');
checksum = 'O';
count = 0;
while(1)
{
if(count == len)
{
break;
}
ch = hexchars[(data[count] >> 4) & 0xF];
pspDebugSioPutchar(ch);
checksum += ch;
ch = hexchars[data[count] & 0xF];
pspDebugSioPutchar(ch);
checksum += ch;
count += 1;
}
pspDebugSioPutchar('#');
pspDebugSioPutchar(hexchars[(checksum >> 4) & 0xf]);
pspDebugSioPutchar(hexchars[checksum & 0xf]);
}
while ((get_char() & 0x7f) != '+');
return count;
}
/*
* Convert ch from a hex digit to an int
*/
static int hex(unsigned char ch)
{
if (ch >= 'a' && ch <= 'f')
return ch-'a'+10;
if (ch >= '0' && ch <= '9')
return ch-'0';
if (ch >= 'A' && ch <= 'F')
return ch-'A'+10;
return -1;
}
/*
* scan for the sequence $<data>#<checksum>
*/
static void getpacket(char *buffer)
{
unsigned char checksum;
unsigned char xmitcsum;
int i;
int count;
unsigned char ch;
do {
/*
* wait around for the start character,
* ignore all other characters
*/
while ((ch = (getDebugChar() & 0x7f)) != '$') ;
checksum = 0;
xmitcsum = -1;
count = 0;
/*
* now, read until a # or end of buffer is found
*/
while (count < MAX_BUF) {
ch = getDebugChar();
if (ch == '#')
break;
checksum = checksum + ch;
buffer[count] = ch;
count = count + 1;
}
if (count >= MAX_BUF)
continue;
buffer[count] = 0;
if (ch == '#') {
xmitcsum = hex(getDebugChar() & 0x7f) << 4;
xmitcsum |= hex(getDebugChar() & 0x7f);
if (checksum != xmitcsum)
putDebugChar('-'); /* failed checksum */
else {
putDebugChar('+'); /* successful transfer */
/*
* if a sequence char is present,
* reply the sequence ID
*/
if (buffer[2] == ':') {
putDebugChar(buffer[0]);
putDebugChar(buffer[1]);
/*
* remove sequence chars from buffer
*/
count = strlen(buffer);
for (i=3; i <= count; i++)
buffer[i-3] = buffer[i];
}
}
}
}
while (checksum != xmitcsum);
}
static struct hard_trap_info {
unsigned char tt; /* Trap type code for MIPS R3xxx and R4xxx */
unsigned char signo; /* Signal that we map this trap into */
} hard_trap_info[] = {
{ 6, SIGBUS }, /* instruction bus error */
{ 7, SIGBUS }, /* data bus error */
{ 9, SIGTRAP }, /* break */
{ 10, SIGILL }, /* reserved instruction */
{ 12, SIGFPE }, /* overflow */
{ 13, SIGTRAP }, /* trap */
{ 14, SIGSEGV }, /* virtual instruction cache coherency */
{ 15, SIGFPE }, /* floating point exception */
{ 23, SIGSEGV }, /* watch */
{ 31, SIGSEGV }, /* virtual data cache coherency */
{ 0, 0} /* Must be last */
};
static int computeSignal(int tt)
{
struct hard_trap_info *ht;
for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
if (ht->tt == tt)
return ht->signo;
return SIGHUP; /* default for things we don't know about */
}
static void _GdbTrapEntry(PspDebugRegBlock *regs)
{
/* Get the current priority and increment by one ? */
_GdbExceptRegs = regs;
handle_exception(regs);
/* Flush caches */
_gdbSupportLibFlushCaches();
pspDebugResumeFromException();
}
int _gdbSupportLibInit(void);
void pspDebugGdbStubInit(void)
{
_gdbSupportLibInit();
/* Read out any pending data */
memset(g_stepbp, 0, 2 * sizeof(struct sw_breakpoint));
pspDebugInstallStdoutHandler(stdout_handler);
pspDebugInstallStderrHandler(stdout_handler);
pspDebugInstallErrorHandler(_GdbTrapEntry);
initialised = 1;
attached = 1;
}
static char *mem2hex(unsigned char *mem, char *buf, int count)
{
unsigned char ch;
while (count-- > 0) {
if (_gdbSupportLibReadByte(mem++, &ch) == 0)
{
return NULL;
}
*buf++ = hexchars[(ch >> 4) & 0xf];
*buf++ = hexchars[ch & 0xf];
}
*buf = 0;
return buf;
}
static char *hex2mem(char *buf, char *mem, int count, int binary)
{
int i;
unsigned char ch;
for (i=0; i<count; i++)
{
if (binary) {
ch = *buf++;
if (ch == 0x7d)
ch = 0x20 ^ *buf++;
}
else {
ch = hex(*buf++) << 4;
ch |= hex(*buf++);
}
if (_gdbSupportLibWriteByte(ch, (unsigned char *) mem++) == 0)
return 0;
}
return mem;
}
static int hexToInt(char **ptr, unsigned int *intValue)
{
int numChars = 0;
int hexValue;
*intValue = 0;
while (**ptr) {
hexValue = hex(**ptr);
if (hexValue < 0)
break;
*intValue = (*intValue << 4) | hexValue;
numChars ++;
(*ptr)++;
}
return numChars;
}
#define SW_BREAK_INST 0x0000000d
/* Define some opcode stuff for the stepping function */
#define BEQ_OPCODE 0x4
#define BEQL_OPCODE 0x14
#define BGTZ_OPCODE 0x7
#define BGTZL_OPCODE 0x17
#define BLEZ_OPCODE 0x6
#define BLEZL_OPCODE 0x16
#define BNE_OPCODE 0x5
#define BNEL_OPCODE 0x15
/* Reg Imm */
#define REGIMM_OPCODE 0x1
#define BGEZ_OPCODE 0x1
#define BGEZAL_OPCODE 0x11
#define BGEZALL_OPCODE 0x13
#define BGEZL_OPCODE 0x3
#define BLTZ_OPCODE 0
#define BLTZAL_OPCODE 0x10
#define BLTZALL_OPCODE 0x12
#define BLTZL_OPCODE 0x2
#define J_OPCODE 0x2
#define JAL_OPCODE 0x3
/* Special opcode */
#define SPECIAL_OPCODE 0
#define JALR_OPCODE 0x9
#define JR_OPCODE 0x8
/* Cop Branches (all the same) */
#define COP0_OPCODE 0x10
#define COP1_OPCODE 0x11
#define COP2_OPCODE 0x12
#define BCXF_OPCODE 0x100
#define BCXFL_OPCODE 0x102
#define BCXT_OPCODE 0x101
#define BCXTL_OPCODE 0x103
/* Generic step command , if skip then will try to skip over jals */
static void step_generic(PspDebugRegBlock *regs, int skip)
{
u32 opcode;
u32 epc;
u32 targetpc;
int branch = 0;
int cond = 0;
int link = 0;
epc = regs->epc;
targetpc = epc + 4;
opcode = _lw(epc);
switch(opcode >> 26)
{
case BEQ_OPCODE:
case BEQL_OPCODE:
case BGTZ_OPCODE:
case BGTZL_OPCODE:
case BLEZ_OPCODE:
case BLEZL_OPCODE:
case BNE_OPCODE:
case BNEL_OPCODE:
{
short ofs;
ofs = (short) (opcode & 0xffff);
cond = 1;
branch = 1;
targetpc += ofs * 4;
}
break;
case REGIMM_OPCODE: {
switch((opcode >> 16) & 0x1f)
{
case BGEZ_OPCODE:
case BGEZAL_OPCODE:
case BGEZALL_OPCODE:
case BGEZL_OPCODE:
case BLTZ_OPCODE:
case BLTZAL_OPCODE:
case BLTZALL_OPCODE:
case BLTZL_OPCODE: {
short ofs;
ofs = (short) (opcode & 0xffff);
cond = 1;
branch = 1;
targetpc += ofs * 4;
}
break;
}
}
break;
case JAL_OPCODE: link = 1;
case J_OPCODE: {
u32 ofs;
ofs = opcode & 0x3ffffff;
targetpc = (ofs << 2) | (targetpc & 0xf0000000);
branch = 1;
cond = 0;
}
break;
case SPECIAL_OPCODE:
{
switch(opcode & 0x3f)
{
case JALR_OPCODE: link = 1;
case JR_OPCODE:
{
u32 rs;
rs = (opcode >> 21) & 0x1f;
targetpc = regs->r[rs];
branch = 1;
cond = 0;
}
break;
};
}
break;
case COP0_OPCODE:
case COP1_OPCODE:
case COP2_OPCODE:
{
switch((opcode >> 16) & 0x3ff)
{
case BCXF_OPCODE:
case BCXFL_OPCODE:
case BCXT_OPCODE:
case BCXTL_OPCODE:
{
short ofs;
ofs = (short) (opcode & 0xffff);
cond = 1;
branch = 1;
targetpc += ofs * 4;
}
break;
};
}
break;
};
if(link && skip)
{
g_stepbp[1].addr = epc + 8;
g_stepbp[1].oldinst = _lw(epc + 8);
g_stepbp[1].active = 1;
_sw(SW_BREAK_INST, epc + 8);
}
else if(branch)
{
g_stepbp[0].addr = targetpc;
g_stepbp[0].oldinst = _lw(targetpc);
g_stepbp[0].active = 1;
_sw(SW_BREAK_INST, targetpc);
if((cond) && (targetpc != (epc + 8)))
{
g_stepbp[1].addr = epc + 8;
g_stepbp[1].oldinst = _lw(epc + 8);
g_stepbp[1].active = 1;
_sw(SW_BREAK_INST, epc + 8);
}
}
else
{
g_stepbp[0].addr = targetpc;
g_stepbp[0].active = 1;
g_stepbp[0].oldinst = _lw(targetpc);
_sw(SW_BREAK_INST, targetpc);
}
}
void build_trap_cmd(int sigval, PspDebugRegBlock *regs)
{
char *ptr;
/*
* reply to host that an exception has occurred
*/
ptr = output;
*ptr++ = 'T';
*ptr++ = hexchars[(sigval >> 4) & 0xf];
*ptr++ = hexchars[sigval & 0xf];
/*
* Send Error PC
*/
*ptr++ = hexchars[37 >> 4];
*ptr++ = hexchars[37 & 0xf];
*ptr++ = ':';
ptr = mem2hex((unsigned char *) &regs->epc, ptr, sizeof(u32));
*ptr++ = ';';
/*
* Send frame pointer
*/
*ptr++ = hexchars[30 >> 4];
*ptr++ = hexchars[30 & 0xf];
*ptr++ = ':';
ptr = mem2hex((unsigned char *)&regs->r[30], ptr, sizeof(u32));
*ptr++ = ';';
/*
* Send stack pointer
*/
*ptr++ = hexchars[29 >> 4];
*ptr++ = hexchars[29 & 0xf];
*ptr++ = ':';
ptr = mem2hex((unsigned char *)&regs->r[29], ptr, sizeof(u32));
*ptr++ = ';';
*ptr++ = 0;
}
static void handle_query(char *str)
{
static SceUID threads[100];
static int thread_count = 0;
static int thread_loc = 0;
switch(str[0])
{
case 'f':
if(strncmp(str, "fThreadInfo", strlen("fThreadInfo")) == 0)
{
thread_count = sceKernelGetThreadmanIdList(SCE_KERNEL_TMID_Thread, threads, 100, &thread_count);
if(thread_count > 0)
{
thread_loc = 0;
output[0] = 'm';
mem2hex((unsigned char *) &threads[thread_loc], &output[1], 4);
output[9] = 0;
thread_loc++;
}
}
break;
case 's':
if(strncmp(str, "sThreadInfo", strlen("sThreadInfo")) == 0)
{
if(thread_loc < thread_count)
{
output[0] = 'm';
mem2hex((unsigned char *) &threads[thread_loc], &output[1], 4);
output[9] = 0;
thread_loc++;
}
else
{
strcpy(output, "l");
}
}
break;
case 'P':
break;
};
}
static void handle_exception (PspDebugRegBlock *regs)
{
int trap;
int sigval;
unsigned int addr;
unsigned int length;
char *ptr;
int bflag = 0;
trap = (regs->cause & 0x7c) >> 2;
sigval = computeSignal(trap);
if(sigval == SIGHUP)
{
DEBUG_PRINTF("Trap %d\n", trap);
}
/* We stopped in breakpoint, so set epc to our ra */
if((regs->epc == (u32) pspDebugBreakpoint) && (trap == 9))
{
regs->epc = regs->r[31];
}
/* If step breakpoints set then put back the old values */
if(g_stepbp[0].active)
{
_sw(g_stepbp[0].oldinst, g_stepbp[0].addr);
g_stepbp[0].active = 0;
}
if(g_stepbp[1].active)
{
_sw(g_stepbp[1].oldinst, g_stepbp[1].addr);
g_stepbp[1].active = 0;
}
if(last_cmd != 0)
{
build_trap_cmd(sigval, regs);
putpacket((unsigned char *) output);
}
while(1)
{
getpacket(input);
DEBUG_PRINTF("Received packet '%s'\n", input);
output[0] = 0;
switch (input[0])
{
case '?':
if(last_cmd == 0)
{
build_trap_cmd(sigval, regs);
}
else
{
output[0] = 'S';
output[1] = hexchars[sigval >> 4];
output[2] = hexchars[sigval & 0xf];
output[3] = 0;
}
break;
case 'c':
ptr = &input[1];
if (hexToInt(&ptr, &addr))
{
regs->epc = addr;
}
goto restart;
break;
case 'D':
putpacket((unsigned char *) output);
attached = 0;
goto restart;
break;
case 'g':
ptr = output;
ptr = (char*) mem2hex((unsigned char *)&regs->r[0], ptr, 32*sizeof(u32)); /* r0...r31 */
ptr = (char*) mem2hex((unsigned char *)&regs->status, ptr, 6*sizeof(u32)); /* cp0 */
ptr = (char*) mem2hex((unsigned char *)&regs->fpr[0], ptr, 32*sizeof(u32)); /* f0...31 */
ptr = (char*) mem2hex((unsigned char *)&regs->fsr, ptr, 2*sizeof(u32)); /* cp1 */
ptr = (char*) mem2hex((unsigned char *)&regs->frame_ptr, ptr, 2*sizeof(u32)); /* frp */
ptr = (char*) mem2hex((unsigned char *)&regs->index, ptr, 16*sizeof(u32)); /* cp0 */
break;
case 'G':
ptr = &input[1];
hex2mem(ptr, (char *)&regs->r[0], 32*sizeof(unsigned int), 0);
ptr += 32*(2*sizeof(unsigned int));
hex2mem(ptr, (char *)&regs->status, 6*sizeof(unsigned int), 0);
ptr += 6*(2*sizeof(unsigned int));
hex2mem(ptr, (char *)&regs->fpr[0], 32*sizeof(unsigned int), 0);
ptr += 32*(2*sizeof(unsigned int));
hex2mem(ptr, (char *)&regs->fsr, 2*sizeof(unsigned int), 0);
ptr += 2*(2*sizeof(unsigned int));
hex2mem(ptr, (char *)&regs->frame_ptr, 2*sizeof(unsigned int), 0);
ptr += 2*(2*sizeof(unsigned int));
hex2mem(ptr, (char *)&regs->index, 16*sizeof(unsigned int), 0);
strcpy(output,"OK");
break;
/*
* mAA..AA,LLLL Read LLLL bytes at address AA..AA
*/
case 'm':
ptr = &input[1];
if (hexToInt(&ptr, &addr)
&& *ptr++ == ','
&& hexToInt(&ptr, &length)) {
if (mem2hex((unsigned char *)addr, output, length))
break;
strcpy (output, "E03");
} else
strcpy(output,"E01");
break;
/*
* XAA..AA,LLLL: Write LLLL escaped binary bytes at address AA.AA
*/
case 'X':
bflag = 1;
/* fall through */
/*
* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK
*/
case 'M':
ptr = &input[1];
if (hexToInt(&ptr, &addr)
&& *ptr++ == ','
&& hexToInt(&ptr, &length)
&& *ptr++ == ':') {
if (hex2mem(ptr, (char *)addr, length, bflag))
strcpy(output, "OK");
else
strcpy(output, "E03");
}
else
strcpy(output, "E02");
bflag = 0;
break;
case 's': ptr = &input[1];
if (hexToInt(&ptr, &addr))
{
regs->epc = addr;
}
step_generic(regs, 0);
goto restart;
break;
case 'q': handle_query(&input[1]);
break;
/*
* kill the program; let us try to restart the machine
* Reset the whole machine.
*/
case 'k':
case 'r': sceKernelExitGame();
break;
default:
break;
}
/*
* reply to the request
*/
putpacket((unsigned char *) output);
} /* while */
restart:
last_cmd = input[0];
return ;
}
/* Define the breakpoint function */
asm (
".global pspDebugBreakpoint\n"
".set noreorder\n"
"pspDebugBreakpoint:\tbreak\n"
"jr $31\n"
"nop\n"
);

195
src/debug/gdb-userlib.c Normal file
View File

@@ -0,0 +1,195 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* gdb-userlib.c - GDB support functions for user mode.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: gdb-userlib.c 2166 2007-02-04 10:52:49Z tyranid $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
static int sio_fd = -1;
/* GDB Debug putchar */
void putDebugChar(char ch)
{
sceIoWrite(sio_fd, &ch, 1);
}
/* GDB Debug getchar */
char getDebugChar(void)
{
char ch = 0;
int count = 0;
while(count <= 0)
{
count = sceIoRead(sio_fd, &ch, 1);
}
return ch;
}
int g_initialised = 0;
static int io_init(PspIoDrvArg *arg)
{
return 0;
}
static int io_exit(PspIoDrvArg *arg)
{
return 0;
}
static int io_read(PspIoDrvFileArg *arg, char *data, int len)
{
int ret = 0;
int ch;
while(ret < len)
{
ch = pspDebugSioGetchar();
if(ch != -1)
{
data[ret++] = ch & 0xFF;
}
else
{
break;
}
}
return ret;
}
static int io_write(PspIoDrvFileArg *arg, const char *data, int len)
{
int ret = 0;
while(ret < len)
{
pspDebugSioPutchar(data[ret++]);
}
return ret;
}
void sceKernelDcacheWBinvAll(void);
void sceKernelIcacheClearAll(void);
static int io_devctl(PspIoDrvFileArg *arg, const char *devname, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen)
{
pspKernelSetKernelPC();
sceKernelDcacheWBinvAll();
sceKernelIcacheClearAll();
return 0;
}
static PspIoDrvFuncs sio_funcs =
{
io_init,
io_exit,
NULL,
NULL,
io_read,
io_write,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
io_devctl,
NULL,
};
static PspIoDrv sio_driver =
{
"sio", 0x10, 0x800, "SIO", &sio_funcs
};
int _gdbSupportLibReadByte(unsigned char *address, unsigned char *dest)
{
u32 addr;
addr = (u32) address;
if((addr >= 0x08400000) && (addr < 0x0a000000))
{
*dest = *address;
return 1;
}
/*
else if((addr >= 0x88000000) && (addr < 0x8a000000))
{
*dest = *address;
return 1;
}
*/
return 0;
}
int _gdbSupportLibWriteByte(char val, unsigned char *dest)
{
u32 addr;
addr = (u32) dest;
if((addr >= 0x08400000) && (addr < 0x0a000000))
{
*dest = val;
return 1;
}
/*
else if((addr >= 0x88000000) && (addr < 0x8a000000))
{
*dest = val;
return 1;
}
*/
return 0;
}
void _gdbSupportLibFlushCaches(void)
{
sceIoDevctl("sio:", 0, NULL, 0, NULL, 0);
}
int _gdbSupportLibInit(void)
{
int ret;
if(!g_initialised)
{
(void) sceIoDelDrv("sio"); /* Ignore error */
ret = sceIoAddDrv(&sio_driver);
if(ret < 0)
{
return ret;
}
sio_fd = sceIoOpen("sio:", PSP_O_RDWR, 0);
g_initialised = 1;
}
return 0;
}

45
src/debug/kprintf.c Normal file
View File

@@ -0,0 +1,45 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* kprintf.c - Basic Kprintf handling for applications.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: kprintf.c 1095 2005-09-27 21:02:16Z jim $
*/
#include <pspkernel.h>
#include <pspdebug.h>
/* The current kprintf handler */
static PspDebugKprintfHandler curr_handler;
int sceKernelRegisterKprintfHandler(void *func, void *args);
/* Default kprintf handler */
static void _pspDebugDefaultKprintfHandler(const char *format, u32 *args)
{
pspDebugScreenPrintf(format, args[0], args[1], args[2], args[3]);
}
/* The registered kprintf handler */
static void _pspDebugKprintfHandler(void *arg, const char *format, u32 *args)
{
if(curr_handler != NULL)
{
curr_handler(format, args);
}
else
{
_pspDebugDefaultKprintfHandler(format, args);
}
}
/* Install a kprintf handler */
int pspDebugInstallKprintfHandler(PspDebugKprintfHandler handler)
{
curr_handler = handler;
return sceKernelRegisterKprintfHandler(_pspDebugKprintfHandler, NULL);
}

97
src/debug/profiler.c Normal file
View File

@@ -0,0 +1,97 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* profiler.c - Debug profiler functions.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: profiler.c 2190 2007-02-25 21:00:40Z tyranid $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#define PROFILER_REG_BASE 0xBC400000
#define PROFILER_REG_COUNT 21
void pspDebugProfilerEnable(void)
{
_sw(1, PROFILER_REG_BASE);
}
void pspDebugProfilerDisable(void)
{
_sw(0, PROFILER_REG_BASE);
asm("sync\r\n");
}
void pspDebugProfilerClear(void)
{
u32 addr;
int i;
addr = PROFILER_REG_BASE;
/* Don't clear the enable register */
for(i = 1; i < PROFILER_REG_COUNT; i++)
{
addr += 4;
_sw(0, addr);
}
}
void pspDebugProfilerGetRegs(PspDebugProfilerRegs *regs)
{
u32 *p_regs;
u32 addr;
int i;
if(regs == NULL)
{
return;
}
p_regs = (u32 *) regs;
addr = PROFILER_REG_BASE;
for(i = 0; i < PROFILER_REG_COUNT; i++)
{
p_regs[i] = _lw(addr);
addr += 4;
}
}
void pspDebugProfilerPrint(void)
{
PspDebugProfilerRegs regs;
pspDebugProfilerGetRegs(&regs);
pspDebugScreenPrintf("********** Profile ***********\n");
pspDebugScreenPrintf("enable : %10u\n", regs.enable);
pspDebugScreenPrintf("systemck : %10u [cycles]\n", regs.systemck);
pspDebugScreenPrintf("cpu ck : %10u [cycles]\n", regs.cpuck);
pspDebugScreenPrintf("stall : %10u [cycles]\n", regs.internal + regs.memory +
regs.copz + regs.vfpu);
pspDebugScreenPrintf("+(internal) : %10u [cycles]\n", regs.internal);
pspDebugScreenPrintf("+--(memory) : %10u [cycles]\n", regs.memory);
pspDebugScreenPrintf("+----(COPz) : %10u [cycles]\n", regs.copz);
pspDebugScreenPrintf("+----(VFPU) : %10u [cycles]\n", regs.vfpu);
pspDebugScreenPrintf("sleep : %10u [cycles]\n", regs.sleep);
pspDebugScreenPrintf("bus access : %10u [cycles]\n", regs.bus_access);
pspDebugScreenPrintf("uncached load : %10u [times]\n", regs.uncached_load);
pspDebugScreenPrintf("uncached store : %10u [times]\n", regs.uncached_store);
pspDebugScreenPrintf("cached load : %10u [times]\n", regs.cached_load);
pspDebugScreenPrintf("cached store : %10u [times]\n", regs.cached_store);
pspDebugScreenPrintf("I cache miss : %10u [times]\n", regs.i_miss);
pspDebugScreenPrintf("D cache miss : %10u [times]\n", regs.d_miss);
pspDebugScreenPrintf("D cache wb : %10u [times]\n", regs.d_writeback);
pspDebugScreenPrintf("COP0 inst. : %10u [inst.]\n", regs.cop0_inst);
pspDebugScreenPrintf("FPU inst. : %10u [inst.]\n", regs.fpu_inst);
pspDebugScreenPrintf("VFPU inst. : %10u [inst.]\n", regs.vfpu_inst);
pspDebugScreenPrintf("local bus : %10u [cycles]\n", regs.local_bus);
}

443
src/debug/pspdebug.h Normal file
View File

@@ -0,0 +1,443 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspdebug.h - Prototypes for the pspDebug library
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: pspdebug.h 2450 2009-01-04 23:53:02Z oopo $
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <psptypes.h>
#include <pspmoduleinfo.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup Debug Debug Utility Library */
/** @addtogroup Debug */
/*@{*/
/**
* Initialise the debug screen
*/
void pspDebugScreenInit(void);
/**
* Extended debug screen init
*
* @param vram_base - Base address of frame buffer, if NULL then sets a default
* @param mode - Colour mode
* @param setup - Setup the screen if 1
*/
void pspDebugScreenInitEx(void *vram_base, int mode, int setup);
/**
* Do a printf to the debug screen.
*
* @param fmt - Format string to print
* @param ... - Arguments
*/
void pspDebugScreenPrintf(const char *fmt, ...) __attribute__((format(printf,1,2)));
/**
* Do a printf to the debug screen.
* @note This is for kernel mode only as it uses a kernel function
* to perform the printf instead of using vsnprintf, use normal printf for
* user mode.
*
* @param format - Format string to print
* @param ... - Arguments
*/
void pspDebugScreenKprintf(const char *format, ...) __attribute__((format(printf,1,2)));
/**
* Enable or disable background colour writing (defaults to enabled)
*
* @param enable - Set 1 to to enable background color, 0 for disable
*/
void pspDebugScreenEnableBackColor(int enable);
/**
* Set the background color for the text
* @note To reset the entire screens bg colour you need to call pspDebugScreenClear
*
* @param color - A 32bit RGB colour
*/
void pspDebugScreenSetBackColor(u32 color);
/**
* Set the text color
*
* @param color - A 32 bit RGB color
*/
void pspDebugScreenSetTextColor(u32 color);
/**
* Set the color mode (you must have switched the frame buffer appropriately)
*
* @param mode - Color mode
*/
void pspDebugScreenSetColorMode(int mode);
/**
* Draw a single character to the screen.
*
* @param x - The x co-ordinate to draw to (pixel units)
* @param y - The y co-ordinate to draw to (pixel units)
* @param color - The text color to draw
* @param ch - The character to draw
*/
void pspDebugScreenPutChar(int x, int y, u32 color, u8 ch);
/**
* Set the current X and Y co-ordinate for the screen (in character units)
*/
void pspDebugScreenSetXY(int x, int y);
/**
* Set the video ram offset used for the screen
*
* @param offset - Offset in bytes
*/
void pspDebugScreenSetOffset(int offset);
/**
* Set the video ram base used for the screen
*
* @param base - Base address in bytes
*/
void pspDebugScreenSetBase(u32* base);
/**
* Get the current X co-ordinate (in character units)
*
* @return The X co-ordinate
*/
int pspDebugScreenGetX(void);
/**
* Get the current Y co-ordinate (in character units)
*
* @return The Y co-ordinate
*/
int pspDebugScreenGetY(void);
/**
* Clear the debug screen.
*/
void pspDebugScreenClear(void);
/**
* Print non-nul terminated strings.
*
* @param buff - Buffer containing the text.
* @param size - Size of the data
*
* @return The number of characters written
*/
int pspDebugScreenPrintData(const char *buff, int size);
/**
* Print a string
*
* @param str - String
*
* @return The number of characters written
*/
int pspDebugScreenPuts(const char *str);
/**
* Get a MIPS stack trace (might work :P)
*
* @param results - List of points to store the results of the trace, (up to max)
* @param max - Maximum number of back traces
*
* @return The number of frames stored in results.
*/
int pspDebugGetStackTrace(unsigned int* results, int max);
/**
* Enable the clear line function that allows debug to clear the screen
*/
void pspDebugScreenClearLineEnable(void);
/**
* Disable the clear line function that causes flicker on constant refreshes
*/
void pspDebugScreenClearLineDisable(void);
/** Structure to hold the register data associated with an exception */
typedef struct _PspDebugRegBlock
{
u32 frame[6];
/** Array of the 32 GPRs */
u32 r[32];
/** The status register */
u32 status;
/** lo */
u32 lo;
u32 hi;
u32 badvaddr;
u32 cause;
u32 epc;
float fpr[32];
u32 fsr;
u32 fir;
u32 frame_ptr;
u32 unused;
/* Unused on PSP */
u32 index;
u32 random;
u32 entrylo0;
u32 entrylo1;
u32 context;
u32 pagemask;
u32 wired;
u32 cop0_7;
u32 cop0_8;
u32 cop0_9;
u32 entryhi;
u32 cop0_11;
u32 cop0_12;
u32 cop0_13;
u32 cop0_14;
/* PRId should still be okay */
u32 prid;
u32 padding[100];
} PspDebugRegBlock;
/** Defines a debug error handler */
typedef void (*PspDebugErrorHandler)(PspDebugRegBlock *regs);
/**
* Install an error handler to catch unhandled exceptions.
*
* @param handler - Pointer to a handler function. If set to NULL it will default
* to resetting the screen and dumping the error.
* @return < 0 on error
*/
int pspDebugInstallErrorHandler(PspDebugErrorHandler handler);
/**
* Dump an exception to screen using the pspDebugScreen functions.
* @note This function will not setup the screen for debug output, you should call sceDebugScreenInit
* before using it if it isn't already.
*
* @param regs - Pointer to a register block.
*
*/
void pspDebugDumpException(PspDebugRegBlock *regs);
/** Type for Kprintf handler */
typedef int (*PspDebugKprintfHandler)(const char *format, u32 *args);
/**
* Install a Kprintf handler into the system.
*
* @param handler - Function pointer to the handler.
* @return < 0 on error.
*/
int pspDebugInstallKprintfHandler(PspDebugKprintfHandler handler);
/** Structure to hold a single stack trace entry */
typedef struct _PspDebugStackTrace
{
/** The address which called the function */
u32 call_addr;
/** The address of the function called */
u32 func_addr;
} PspDebugStackTrace;
/**
* Do a stack trace from the current exception.
* @note This function really isn't too general purpose and it is more than likely to generate a few
* false positives but I consider that better then missing out calls entirely. You have to use your
* discretion, your code and a objdump to work out if some calls are completely surprious or not ;)
*
* @param regs - Pointer to a register block from an exception.
* @param trace - Pointer to an array of PspDebugStackTrace structures.
* @param max - The maximum number of traces to make.
*
* @return The number of functions found.
*/
int pspDebugGetStackTrace2(PspDebugRegBlock *regs, PspDebugStackTrace *trace, int max);
/** Structure to hold the psp profiler register values */
typedef struct _PspDebugProfilerRegs
{
volatile u32 enable;
volatile u32 systemck;
volatile u32 cpuck;
volatile u32 internal;
volatile u32 memory;
volatile u32 copz;
volatile u32 vfpu;
volatile u32 sleep;
volatile u32 bus_access;
volatile u32 uncached_load;
volatile u32 uncached_store;
volatile u32 cached_load;
volatile u32 cached_store;
volatile u32 i_miss;
volatile u32 d_miss;
volatile u32 d_writeback;
volatile u32 cop0_inst;
volatile u32 fpu_inst;
volatile u32 vfpu_inst;
volatile u32 local_bus;
} PspDebugProfilerRegs;
/** Enables the profiler hardware */
void pspDebugProfilerEnable(void);
/** Disables the profiler hardware */
void pspDebugProfilerDisable(void);
/** Clear the profiler registers */
void pspDebugProfilerClear(void);
/** Get the profiler register state
*
* @param regs - A pointer to a PspDebugProfilerRegs structure.
*/
void pspDebugProfilerGetRegs(PspDebugProfilerRegs *regs);
/** Print the profiler registers to screen */
void pspDebugProfilerPrint(void);
/** Type for the debug print handlers */
typedef int (*PspDebugPrintHandler)(const char *data, int len);
/** Type for the debug input handler */
typedef int (*PspDebugInputHandler)(char *data, int len);
/**
* Install a handler for stdin (so you can use normal stdio functions)
*
* @param handler - A pointer to input handler, NULL to disable.
*
* @return < 0 on error, else 0.
*/
int pspDebugInstallStdinHandler(PspDebugInputHandler handler);
/**
* Install a print handler for stdout (so you can use normal print functions)
*
* @param handler - A pointer to print handler, NULL to disable.
*
* @return < 0 on error, else 0.
*/
int pspDebugInstallStdoutHandler(PspDebugPrintHandler handler);
/**
* Install a print handler for stderr (so you can use normal print functions)
*
* @param handler - A pointer to print handler, NULL to disable.
*
* @return < 0 on error, else 0.
*/
int pspDebugInstallStderrHandler(PspDebugPrintHandler handler);
/**
* Put a character to the remote sio.
*
* @param ch - Character to write.
*/
void pspDebugSioPutchar(int ch);
/**
* Get a character from the remote sio
*
* @return The character read or -1 if no characters available.
*/
int pspDebugSioGetchar(void);
/**
* Write a string to the sio port.
*
* @param str - String to write.
*/
void pspDebugSioPuts(const char *str);
/**
* Write a set of data to the sio port
*
* @param data - Pointer to the data to send.
* @param len - Length of the data.
*
* @return Number of characters written.
*/
int pspDebugSioPutData(const char *data, int len);
/**
* Write a set of data to the sio port converting single
* line feeds to CRLF and single CR to CRLF
*
* @param data - Pointer to the data to send.
* @param len - Length of the data.
*
* @return Number of characters written.
*/
int pspDebugSioPutText(const char *data, int len);
/**
* Initialise the remote SIO port (defaults to 4800 8N1).
* @note will delay 2 seconds to wait for the power to come up.
*/
void pspDebugSioInit(void);
/**
* Set the baud rate of the SIO, e.g. 4800/9600..115200.
* @param baud - The baudrate to set.
*/
void pspDebugSioSetBaud(int baud);
/**
* Enable debug character output. Needs to be called in order
* for the default Kprintf handler to work.
*/
void pspDebugEnablePutchar(void);
/**
* Install a kprintf debug putchar handler. Implicitly calls ::pspDebugEnablePutchar
* so you do not need to call it explicitly. Sio must be initialised before calling
* this function however.
*/
void pspDebugSioInstallKprintf(void);
/**
* Install the gdb stub handler.
*/
void pspDebugGdbStubInit(void);
/**
* Generate a breakpoint exception.
*/
void pspDebugBreakpoint(void);
/**
* Enable the kprintf handler (once installed)
*/
void pspDebugSioEnableKprintf(void);
/**
* Disable the kprintf handler (once installed)
*/
void pspDebugSioDisableKprintf(void);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif

292
src/debug/pspdebugkb.c Normal file
View File

@@ -0,0 +1,292 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspdebugkb.c - Simple screen debug keyboard
*
* Copyright (c) 2006 Mike Mallett <mike@nerdcore.net>
*
* $Id: pspdebugkb.c 2112 2006-12-22 10:53:20Z tyranid $
*/
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdio.h>
#include <string.h>
#include "pspdebugkb.h"
static char loCharTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS] = {
{ '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=' },
{ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\' },
{ '\0', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '\0' },
{ '\0', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '\0', '\0' }
};
static char hiCharTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS] = {
{ '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+' },
{ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '|' },
{ '\0', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '\0' },
{ '\0', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', '\0', '\0' }
};
static char *commandRow[] = { "Shift", "[ ]", "Back", "Clear", "Done" };
char charTable[PSP_DEBUG_KB_NUM_ROWS][PSP_DEBUG_KB_NUM_CHARS];
/* Switch charTable when Shift is pressed */
void pspDebugKbShift(int* shiftState) {
int i, j;
if (*shiftState != 0) {
for (i=0; i<PSP_DEBUG_KB_NUM_ROWS; i++) {
for (j=0; j<PSP_DEBUG_KB_NUM_CHARS; j++) {
charTable[i][j] = loCharTable[i][j];
}
}
*shiftState = 0;
} else {
for (i=0; i<PSP_DEBUG_KB_NUM_ROWS; i++) {
for (j=0; j<PSP_DEBUG_KB_NUM_CHARS; j++) {
charTable[i][j] = hiCharTable[i][j];
}
}
*shiftState = 1;
}
pspDebugKbDrawBox();
}
void pspDebugKbDrawKey(int row, int col, int highlight) {
int i;
int spacing = 0;
int charsTo = 0;
int charsTotal = 0;
if (highlight) {
pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_HIGHLIGHT);
pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_HIGHLIGHT);
} else {
pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR);
pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR);
}
if (row == PSP_DEBUG_KB_COMMAND_ROW) {
for (i=0; i<PSP_DEBUG_KB_NUM_COMMANDS; i++) {
charsTotal += strlen(commandRow[i]);
if (i < col) { charsTo += strlen(commandRow[i]); }
}
spacing = (PSP_DEBUG_KB_BOX_WIDTH - charsTotal) / (PSP_DEBUG_KB_NUM_COMMANDS + 1);
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + (spacing * (col + 1)) + charsTo, PSP_DEBUG_KB_BOX_Y + (PSP_DEBUG_KB_SPACING_Y * (row + 2)));
pspDebugScreenPrintf("%s", commandRow[col]);
} else {
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_OFFSET_X + (PSP_DEBUG_KB_SPACING_X * col), PSP_DEBUG_KB_BOX_Y + (PSP_DEBUG_KB_SPACING_Y * (row + 2)));
if (charTable[row][col] == '\0') {
pspDebugScreenPrintf(" ");
} else {
pspDebugScreenPrintf("%c", charTable[row][col]);
}
}
}
void pspDebugKbClearBox() {
int i, j;
pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR);
pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR);
for (i = PSP_DEBUG_KB_BOX_X; i <= PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_BOX_WIDTH; i++) {
for (j = PSP_DEBUG_KB_BOX_Y; j <= PSP_DEBUG_KB_BOX_Y + PSP_DEBUG_KB_BOX_HEIGHT; j++) {
pspDebugScreenSetXY(i, j);
pspDebugScreenPrintf(" ");
}
}
}
void pspDebugKbDrawBox() {
int i, j;
pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR);
pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR);
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X, PSP_DEBUG_KB_BOX_Y);
pspDebugScreenPrintf("+");
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X, PSP_DEBUG_KB_BOX_Y + PSP_DEBUG_KB_BOX_HEIGHT);
pspDebugScreenPrintf("+");
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_BOX_WIDTH, PSP_DEBUG_KB_BOX_Y);
pspDebugScreenPrintf("+");
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_BOX_WIDTH, PSP_DEBUG_KB_BOX_Y + PSP_DEBUG_KB_BOX_HEIGHT);
pspDebugScreenPrintf("+");
for (i = 1; i < PSP_DEBUG_KB_BOX_WIDTH; i++) {
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + i, PSP_DEBUG_KB_BOX_Y);
pspDebugScreenPrintf("-");
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + i, PSP_DEBUG_KB_BOX_Y + PSP_DEBUG_KB_BOX_HEIGHT);
pspDebugScreenPrintf("-");
}
for (i = 1; i < PSP_DEBUG_KB_BOX_HEIGHT; i++) {
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X, PSP_DEBUG_KB_BOX_Y + i);
pspDebugScreenPrintf("|");
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_BOX_WIDTH, PSP_DEBUG_KB_BOX_Y + i);
pspDebugScreenPrintf("|");
}
for (i = 0; i < PSP_DEBUG_KB_NUM_ROWS; i++) {
for (j = 0; j < PSP_DEBUG_KB_NUM_CHARS; j++) {
pspDebugKbDrawKey(i, j, 0);
}
}
for (i = 0; i < PSP_DEBUG_KB_NUM_COMMANDS; i++) {
pspDebugKbDrawKey(PSP_DEBUG_KB_COMMAND_ROW, i, 0);
}
}
void pspDebugKbDrawString(char* str) {
int i;
pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR);
pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR);
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + ((PSP_DEBUG_KB_BOX_WIDTH - PSP_DEBUG_KB_MAXLEN) / 2), PSP_DEBUG_KB_BOX_Y + 1);
for (i=0; i<PSP_DEBUG_KB_MAXLEN; i++) {
pspDebugScreenPrintf("_");
}
pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + ((PSP_DEBUG_KB_BOX_WIDTH - PSP_DEBUG_KB_MAXLEN) / 2), PSP_DEBUG_KB_BOX_Y + 1);
pspDebugScreenPrintf("%s", str);
}
void pspDebugKbInit(char* str) {
int row = PSP_DEBUG_KB_COMMAND_ROW;
int col = PSP_DEBUG_KB_NUM_COMMANDS - 1;
int shifted = 1;
int inputDelay = 200000;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL);
SceCtrlData input, lastinput;
sceCtrlReadBufferPositive(&input, 1);
sceCtrlReadBufferPositive(&lastinput, 1);
unsigned int inputTime = input.TimeStamp;
pspDebugKbClearBox();
// Initialize charTable
pspDebugKbShift(&shifted);
pspDebugKbDrawBox();
pspDebugKbDrawKey(row, col, 1);
pspDebugKbDrawString(str);
while (1) {
sceCtrlReadBufferPositive(&input, 1);
if (input.Buttons & PSP_CTRL_LEFT && col > 0
&& (row == PSP_DEBUG_KB_COMMAND_ROW || charTable[row][col - 1])
&& (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) {
// Unhighlight the old character
pspDebugKbDrawKey(row, col, 0);
// Print the new character highlighted
pspDebugKbDrawKey(row, --col, 1);
// Update inputTime
inputTime = input.TimeStamp;
}
if (input.Buttons & PSP_CTRL_RIGHT
&& ((row == PSP_DEBUG_KB_COMMAND_ROW && col < PSP_DEBUG_KB_NUM_COMMANDS - 1)
|| (row != PSP_DEBUG_KB_COMMAND_ROW && col < PSP_DEBUG_KB_NUM_CHARS - 1
&& charTable[row][col + 1]))
&& (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) {
pspDebugKbDrawKey(row, col, 0);
pspDebugKbDrawKey(row, ++col, 1);
inputTime = input.TimeStamp;
}
if (input.Buttons & PSP_CTRL_UP && row > 0
&& (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) {
if (row == PSP_DEBUG_KB_COMMAND_ROW) {
pspDebugKbDrawKey(row, col, 0);
if (col == PSP_DEBUG_KB_NUM_COMMANDS - 1) {
col = PSP_DEBUG_KB_NUM_CHARS - 1;
} else {
col = (col * (PSP_DEBUG_KB_NUM_CHARS - 1)) / (PSP_DEBUG_KB_NUM_COMMANDS - 1);
}
do {
row--;
} while (charTable[row][col] == '\0' && row > 0);
pspDebugKbDrawKey(row, col, 1);
} else if (charTable[row - 1][col]) {
pspDebugKbDrawKey(row, col, 0);
pspDebugKbDrawKey(--row, col, 1);
}
inputTime = input.TimeStamp;
}
if (input.Buttons & PSP_CTRL_DOWN && row != PSP_DEBUG_KB_COMMAND_ROW
&& (input.Buttons != lastinput.Buttons || input.TimeStamp >= inputTime + inputDelay)) {
pspDebugKbDrawKey(row, col, 0);
do {
row++;
} while (charTable[row][col] == '\0' &&
row != PSP_DEBUG_KB_COMMAND_ROW);
if (row == PSP_DEBUG_KB_COMMAND_ROW) {
col = (col * (PSP_DEBUG_KB_NUM_COMMANDS - 1)) / (PSP_DEBUG_KB_NUM_CHARS - 1);
}
pspDebugKbDrawKey(row, col, 1);
inputTime = input.TimeStamp;
}
if (input.Buttons != lastinput.Buttons && input.Buttons & PSP_CTRL_SELECT) {
pspDebugKbShift(&shifted);
pspDebugKbDrawKey(row, col, 1);
}
if (input.Buttons != lastinput.Buttons
&& (input.Buttons & PSP_CTRL_CROSS || input.Buttons & PSP_CTRL_CIRCLE)) {
if (row == PSP_DEBUG_KB_COMMAND_ROW) {
switch(col) {
case 0: // Shift
pspDebugKbShift(&shifted);
pspDebugKbDrawKey(row, col, 1);
break;
case 1: // Space
if (strlen(str) < PSP_DEBUG_KB_MAXLEN) {
snprintf(str, strlen(str)+2, "%s ", str);
pspDebugKbDrawString(str);
}
break;
case 2: // Back
if (strlen(str) > 0) {
str[strlen(str)-1] = '\0';
pspDebugKbDrawString(str);
}
break;
case 3: // Clear
bzero(str, PSP_DEBUG_KB_MAXLEN);
pspDebugKbDrawString(str);
break;
case 4:
// Clean up the screen
pspDebugKbClearBox();
return;
};
} else {
if (strlen(str) < PSP_DEBUG_KB_MAXLEN) {
snprintf(str, strlen(str)+2, "%s%c", str, charTable[row][col]);
pspDebugKbDrawString(str);
}
}
}
if (input.Buttons != lastinput.Buttons
&& (input.Buttons & PSP_CTRL_TRIANGLE || input.Buttons & PSP_CTRL_SQUARE)) {
if (strlen(str) > 0) {
str[strlen(str)-1] = '\0';
pspDebugKbDrawString(str);
}
}
lastinput = input;
}
}

96
src/debug/pspdebugkb.h Normal file
View File

@@ -0,0 +1,96 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspdebugkb.h - Simple screen debug keyboard
*
* Copyright (c) 2006 Mike Mallett <mike@nerdcore.net>
*
* $Id: pspdebugkb.h 2110 2006-12-19 14:50:27Z tyranid $
*/
#ifndef __PSPDEBUGKB_H
#define __PSPDEBUGKB_H
#ifdef __cplusplus
extern "C" {
#endif
enum PspDebugKbSettings {
/** Maximum string length */
PSP_DEBUG_KB_MAXLEN = 40,
/** Place the box' upper-left corner at this location */
PSP_DEBUG_KB_BOX_X = 6,
PSP_DEBUG_KB_BOX_Y = 8,
/** FG and BG colour of unhighlighted characters */
PSP_DEBUG_KB_CHAR_COLOUR = 0xffffffff,
PSP_DEBUG_KB_BACK_COLOUR = 0xff000000,
/** FG and BG colour of highlighted character */
PSP_DEBUG_KB_CHAR_HIGHLIGHT = 0xff00ff00,
PSP_DEBUG_KB_BACK_HIGHLIGHT = 0xff101010,
/** Indent the printed characters by (X_OFFSET,Y_OFFSET) */
PSP_DEBUG_KB_OFFSET_X = 6,
PSP_DEBUG_KB_OFFSET_Y = 4,
/** Distance from one character to the next */
PSP_DEBUG_KB_SPACING_X = 3,
PSP_DEBUG_KB_SPACING_Y = 2,
/** Number of columns/rows (respectively) in charTable(s) */
PSP_DEBUG_KB_NUM_CHARS = 13,
PSP_DEBUG_KB_NUM_ROWS = 4,
/** Box width and height */
PSP_DEBUG_KB_BOX_WIDTH = (PSP_DEBUG_KB_NUM_CHARS * PSP_DEBUG_KB_SPACING_X) + (2 * PSP_DEBUG_KB_OFFSET_X),
PSP_DEBUG_KB_BOX_HEIGHT = ((PSP_DEBUG_KB_NUM_ROWS + 1) * PSP_DEBUG_KB_SPACING_Y) + PSP_DEBUG_KB_OFFSET_Y,
/** Array index of commandRow */
PSP_DEBUG_KB_COMMAND_ROW = 4,
/** Number of commands on bottom row */
PSP_DEBUG_KB_NUM_COMMANDS = 5
};
/**
* Switch charTable when SHIFT is pressed
*
* @param shiftState - Pointer to an int indicating Caps Lock
*/
void pspDebugKbShift(int *shiftState);
/**
* Draw the specified key on the keyboard.
*
* @param row - The row of the character to print (in charTable)
* @param col - The column of the character to print (in charTable)
* @param highlight - 0 for plain; otherwise highlighted
*/
void pspDebugKbDrawKey(int row, int col, int highlight);
/**
* Draw the string at the top of the box
*
* @param str - The string to print
*/
void pspDebugKbDrawString(char *str);
/**
* Clear the area where the box resides.
* Called from pspDebugKbDrawBox and pspDebugKbInit (on exit).
*/
void pspDebugKbClearBox();
/**
* Draw the entire box on the desbug screen.
* Called from shift() and doInputBox(char*)
*/
void pspDebugKbDrawBox();
/**
* Make the text box happen
*
* @param str - The string to edit
*/
void pspDebugKbInit(char *str);
#ifdef __cplusplus
}
#endif
#endif

478
src/debug/scr_printf.c Normal file
View File

@@ -0,0 +1,478 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* scr_printf.c - Debug screen functions.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: scr_printf.c 2450 2009-01-04 23:53:02Z oopo $
*/
#include <stdio.h>
#include <psptypes.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspsysclib.h>
#include <pspge.h>
#include <stdarg.h>
#include <pspdebug.h>
#include <string.h>
#define PSP_SCREEN_WIDTH 480
#define PSP_SCREEN_HEIGHT 272
#define PSP_LINE_SIZE 512
/* baseado nas libs do Duke... */
#ifdef F_pspDebugScreenInit
void _pspDebugScreenClearLine( int Y);
static int X = 0, Y = 0;
static int MX=68, MY=34;
static u32 bg_col = 0, fg_col = 0xFFFFFFFF;
static int bg_enable = 1;
static void* g_vram_base = (u32 *) 0x04000000;
static int g_vram_offset = 0;
static int g_vram_mode = PSP_DISPLAY_PIXEL_FORMAT_8888;
static int init = 0;
static int clearline_en = 1;
static u16 convert_8888_to_565(u32 color)
{
int r, g, b;
b = (color >> 19) & 0x1F;
g = (color >> 10) & 0x3F;
r = (color >> 3) & 0x1F;
return r | (g << 5) | (b << 11);
}
static u16 convert_8888_to_5551(u32 color)
{
int r, g, b, a;
a = (color >> 24) ? 0x8000 : 0;
b = (color >> 19) & 0x1F;
g = (color >> 11) & 0x1F;
r = (color >> 3) & 0x1F;
return a | r | (g << 5) | (b << 10);
}
static u16 convert_8888_to_4444(u32 color)
{
int r, g, b, a;
a = (color >> 28) & 0xF;
b = (color >> 20) & 0xF;
g = (color >> 12) & 0xF;
r = (color >> 4) & 0xF;
return (a << 12) | r | (g << 4) | (b << 8);
}
static void clear_screen_16(u16 color)
{
int x;
u16 *vram = g_vram_base;
vram += (g_vram_offset >> 1);
for(x = 0; x < (PSP_LINE_SIZE * PSP_SCREEN_HEIGHT); x++)
{
*vram++ = color;
}
}
static void clear_screen_32(u32 color)
{
int x;
u32 *vram = g_vram_base;
vram += (g_vram_offset>>2);
for(x = 0; x < (PSP_LINE_SIZE * PSP_SCREEN_HEIGHT); x++)
{
*vram++ = color;
}
}
static void clear_screen(u32 color)
{
if(g_vram_mode == PSP_DISPLAY_PIXEL_FORMAT_8888)
{
clear_screen_32(color);
}
else
{
u16 c = 0;
switch(g_vram_mode)
{
case PSP_DISPLAY_PIXEL_FORMAT_565: c = convert_8888_to_565(color);
break;
case PSP_DISPLAY_PIXEL_FORMAT_5551: c = convert_8888_to_5551(color);
break;
case PSP_DISPLAY_PIXEL_FORMAT_4444: c = convert_8888_to_4444(color);
break;
};
clear_screen_16(c);
}
}
void pspDebugScreenInitEx(void *vram_base, int mode, int setup)
{
switch(mode)
{
case PSP_DISPLAY_PIXEL_FORMAT_565:
case PSP_DISPLAY_PIXEL_FORMAT_5551:
case PSP_DISPLAY_PIXEL_FORMAT_4444:
case PSP_DISPLAY_PIXEL_FORMAT_8888:
break;
default: mode = PSP_DISPLAY_PIXEL_FORMAT_8888;
};
X = Y = 0;
/* Place vram in uncached memory */
if(vram_base == NULL)
{
vram_base = (void*) (0x40000000 | (u32) sceGeEdramGetAddr());
}
g_vram_base = vram_base;
g_vram_offset = 0;
g_vram_mode = mode;
if(setup)
{
sceDisplaySetMode(0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
sceDisplaySetFrameBuf((void *) g_vram_base, PSP_LINE_SIZE, mode, 1);
}
clear_screen(bg_col);
init = 1;
}
void pspDebugScreenInit()
{
X = Y = 0;
pspDebugScreenInitEx(NULL, PSP_DISPLAY_PIXEL_FORMAT_8888, 1);
}
void pspDebugScreenEnableBackColor(int enable)
{
bg_enable = enable;
}
void pspDebugScreenSetBackColor(u32 colour)
{
bg_col = colour;
}
void pspDebugScreenSetTextColor(u32 colour)
{
fg_col = colour;
}
void pspDebugScreenSetColorMode(int mode)
{
switch(mode)
{
case PSP_DISPLAY_PIXEL_FORMAT_565:
case PSP_DISPLAY_PIXEL_FORMAT_5551:
case PSP_DISPLAY_PIXEL_FORMAT_4444:
case PSP_DISPLAY_PIXEL_FORMAT_8888:
break;
default: mode = PSP_DISPLAY_PIXEL_FORMAT_8888;
};
g_vram_mode = mode;
}
int pspDebugScreenGetX()
{
return X;
}
int pspDebugScreenGetY()
{
return Y;
}
void pspDebugScreenClear()
{
int y;
if(!init)
{
return;
}
for(y=0;y<MY;y++)
{
_pspDebugScreenClearLine(y);
}
pspDebugScreenSetXY(0,0);
clear_screen(bg_col);
}
void pspDebugScreenSetXY(int x, int y)
{
if( x<MX && x>=0 ) X=x;
if( y<MY && y>=0 ) Y=y;
}
void pspDebugScreenSetOffset(int offset)
{
g_vram_offset = offset;
}
void pspDebugScreenSetBase(u32* base)
{
g_vram_base = base;
}
extern u8 msx[];
static void debug_put_char_32(int x, int y, u32 color, u32 bgc, u8 ch)
{
int i,j, l;
u8 *font;
u32 *vram_ptr;
u32 *vram;
if(!init)
{
return;
}
vram = g_vram_base;
vram += (g_vram_offset >> 2) + x;
vram += (y * PSP_LINE_SIZE);
font = &msx[ (int)ch * 8];
for (i=l=0; i < 8; i++, l+= 8, font++)
{
vram_ptr = vram;
for (j=0; j < 8; j++)
{
if ((*font & (128 >> j)))
*vram_ptr = color;
else if(bg_enable)
*vram_ptr = bgc;
vram_ptr++;
}
vram += PSP_LINE_SIZE;
}
}
static void debug_put_char_16(int x, int y, u16 color, u16 bgc, u8 ch)
{
int i,j, l;
u8 *font;
u16 *vram_ptr;
u16 *vram;
if(!init)
{
return;
}
vram = g_vram_base;
vram += (g_vram_offset >> 1) + x;
vram += (y * PSP_LINE_SIZE);
font = &msx[ (int)ch * 8];
for (i=l=0; i < 8; i++, l+= 8, font++)
{
vram_ptr = vram;
for (j=0; j < 8; j++)
{
if ((*font & (128 >> j)))
*vram_ptr = color;
else if(bg_enable)
*vram_ptr = bgc;
vram_ptr++;
}
vram += PSP_LINE_SIZE;
}
}
void
pspDebugScreenPutChar( int x, int y, u32 color, u8 ch)
{
if(g_vram_mode == PSP_DISPLAY_PIXEL_FORMAT_8888)
{
debug_put_char_32(x, y, color, bg_col, ch);
}
else
{
u16 c = 0;
u16 b = 0;
switch(g_vram_mode)
{
case PSP_DISPLAY_PIXEL_FORMAT_565: c = convert_8888_to_565(color);
b = convert_8888_to_565(bg_col);
break;
case PSP_DISPLAY_PIXEL_FORMAT_5551: c = convert_8888_to_5551(color);
b = convert_8888_to_5551(bg_col);
break;
case PSP_DISPLAY_PIXEL_FORMAT_4444: c = convert_8888_to_4444(color);
b = convert_8888_to_4444(bg_col);
break;
};
debug_put_char_16(x, y, c, b, ch);
}
}
void _pspDebugScreenClearLine( int Y)
{
if(clearline_en)
{
int i;
if(bg_enable)
{
for (i=0; i < MX; i++)
{
pspDebugScreenPutChar( i*7 , Y * 8, bg_col, 219);
}
}
}
return;
}
void pspDebugScreenClearLineEnable(void)
{
clearline_en = 1;
return;
}
void pspDebugScreenClearLineDisable(void)
{
clearline_en = 0;
return;
}
/* Print non-nul terminated strings */
int pspDebugScreenPrintData(const char *buff, int size)
{
int i;
int j;
char c;
if(!init)
{
return 0;
}
for (i = 0; i < size; i++)
{
c = buff[i];
switch (c)
{
case '\r':
X = 0;
break;
case '\n':
X = 0;
Y ++;
if (Y == MY)
Y = 0;
_pspDebugScreenClearLine(Y);
break;
case '\t':
for (j = 0; j < 5; j++) {
pspDebugScreenPutChar( X*7 , Y * 8, fg_col, ' ');
X++;
}
break;
default:
pspDebugScreenPutChar( X*7 , Y * 8, fg_col, c);
X++;
if (X == MX)
{
X = 0;
Y++;
if (Y == MY)
Y = 0;
_pspDebugScreenClearLine(Y);
}
}
}
return i;
}
int pspDebugScreenPuts(const char *str)
{
return pspDebugScreenPrintData(str, strlen(str));
}
#endif
#ifdef F_pspDebugScreenPrintf
void pspDebugScreenPrintf(const char *format, ...)
{
va_list opt;
char buff[2048];
int bufsz;
va_start(opt, format);
bufsz = vsnprintf( buff, (size_t) sizeof(buff), format, opt);
(void) pspDebugScreenPrintData(buff, bufsz);
}
#endif
/* Kernel screen printf, uses the prnt function instead of vsnprintf */
#ifdef F_pspDebugScreenKprintf
#define MAX_CLI 4096
#define CTX_BUF_SIZE 128
struct prnt_ctx
{
unsigned short len;
char buf[CTX_BUF_SIZE];
};
static void cb(struct prnt_ctx *ctx, int type)
{
if(type == 0x200)
{
ctx->len = 0;
}
else if(type == 0x201)
{
pspDebugScreenPrintData(ctx->buf, ctx->len);
ctx->len = 0;
}
else
{
if(type != '\r')
{
ctx->buf[ctx->len++] = type;
if(ctx->len == CTX_BUF_SIZE)
{
pspDebugScreenPrintData(ctx->buf, ctx->len);
ctx->len = 0;
}
}
}
}
void pspDebugScreenKprintf(const char *format, ...)
{
struct prnt_ctx ctx;
va_list opt;
ctx.len = 0;
va_start(opt, format);
prnt((prnt_callback) cb, (void*) &ctx, format, opt);
va_end(opt);
}
#endif

178
src/debug/sio.c Normal file
View File

@@ -0,0 +1,178 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* sio.c - Some basic SIO (remote port) functions.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: sio.c 2152 2007-01-27 10:09:15Z tyranid $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspsyscon.h>
/* Define some important parameters, not really sure on names. Probably doesn't matter */
#define PSP_UART4_FIFO 0xBE500000
#define PSP_UART4_STAT 0xBE500018
#define PSP_UART4_DIV1 0xBE500024
#define PSP_UART4_DIV2 0xBE500028
#define PSP_UART4_CTRL 0xBE50002C
#define PSP_UART_CLK 96000000
#define PSP_UART_TXFULL 0x20
#define PSP_UART_RXEMPTY 0x10
static int g_enablekprintf = 0;
/* Some function prototypes we will need */
int sceHprmEnd(void);
int sceSysregUartIoEnable(int uart);
extern u32 sceKernelRemoveByDebugSection;
void pspDebugSioPutchar(int ch)
{
while(_lw(PSP_UART4_STAT) & PSP_UART_TXFULL);
_sw(ch, PSP_UART4_FIFO);
}
int pspDebugSioGetchar(void)
{
if(_lw(PSP_UART4_STAT) & PSP_UART_RXEMPTY)
{
return -1;
}
return _lw(PSP_UART4_FIFO);
}
void pspDebugSioPuts(const char *str)
{
while(*str)
{
pspDebugSioPutchar(*str);
str++;
}
pspDebugSioPutchar('\r');
pspDebugSioPutchar('\n');
}
int pspDebugSioPutData(const char *data, int len)
{
int i;
for(i = 0; i < len; i++)
{
pspDebugSioPutchar(data[i]);
}
return len;
}
/* Put data to SIO converting any line feeds as necessary */
int pspDebugSioPutText(const char *data, int len)
{
int i;
for(i = 0; i < len; i++)
{
/* If just line feed add a carriage return */
if(data[i] == '\n')
{
if(((i > 0) && (data[i-1] != '\r')) || (i == 0))
{
pspDebugSioPutchar('\r');
}
}
pspDebugSioPutchar(data[i]);
if((i < (len - 1)) && (data[i] == '\r') && (data[i+1] != '\n'))
{
pspDebugSioPutchar('\n');
}
}
return len;
}
void pspDebugSioSetBaud(int baud)
{
int div1, div2;
/* rate set using the rough formula div1 = (PSP_UART_CLK / baud) >> 6 and
* div2 = (PSP_UART_CLK / baud) & 0x3F
* The uart4 driver actually uses a slightly different formula for div 2 (it
* adds 32 before doing the AND, but it doesn't seem to make a difference
*/
div1 = PSP_UART_CLK / baud;
div2 = div1 & 0x3F;
div1 >>= 6;
_sw(div1, PSP_UART4_DIV1);
_sw(div2, PSP_UART4_DIV2);
_sw(0x60, PSP_UART4_CTRL);
}
void pspDebugSioInit(void)
{
/* Shut down the remote driver */
sceHprmEnd();
/* Enable UART 4 */
sceSysregUartIoEnable(4);
/* Enable remote control power */
sceSysconCtrlHRPower(1);
/* Delay thread for a but */
sceKernelDelayThread(2000000);
}
static u32 *get_debug_register(void)
{
u32 *pData;
u32 ptr;
pData = (u32 *) (0x80000000 | ((sceKernelRemoveByDebugSection & 0x03FFFFFF) << 2));
ptr = ((pData[0] & 0xFFFF) << 16) + (short) (pData[2] & 0xFFFF);
return (u32 *) ptr;
}
void pspDebugEnablePutchar(void)
{
u32 *pData;
pData = get_debug_register();
*pData |= 0x1000;
}
static void PutCharDebug(unsigned short *data, unsigned int type)
{
if(((type & 0xFF00) == 0) && (g_enablekprintf))
{
if(type == '\n')
{
pspDebugSioPutchar('\r');
}
pspDebugSioPutchar(type);
}
}
void pspDebugSioInstallKprintf(void)
{
pspDebugEnablePutchar();
sceKernelRegisterDebugPutchar(PutCharDebug);
g_enablekprintf = 1;
}
void pspDebugSioEnableKprintf(void)
{
g_enablekprintf = 1;
}
void pspDebugSioDisableKprintf(void)
{
g_enablekprintf = 0;
}

111
src/debug/stacktrace.c Normal file
View File

@@ -0,0 +1,111 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* callstack.c - Return stack generation for MIPS processors.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: stacktrace.c 1095 2005-09-27 21:02:16Z jim $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <string.h>
#define CALL 0x0C000000
#define CALL_MASK 0xFC000000
#define IS_CALL(x) (((x) & CALL_MASK) == CALL)
#define CALL_ADDR(x) (((x) & ~CALL_MASK) << 2)
extern u32 _ftext;
extern u32 _etext;
/* Ideally should be something which is automatic */
#define ELF_START (&_ftext)
#define ELF_END (&_etext)
/* This is a blatently wrong way of doing a stack trace, but I felt as long as you use some intelligence you
could easily work out if some calls in the trace were invalid :P */
static int _pspDebugDoStackTrace(u32 *sp, u32 *sp_end, u32 *ra, PspDebugStackTrace *trace, int max)
{
int count = 0;
int recurse = 0;
if((ra >= (ELF_START + 2)) && (ra < ELF_END) && (IS_CALL(ra[-2])))
{
trace[count].func_addr = CALL_ADDR(ra[-2]);
trace[count].call_addr = (u32) (&ra[-2]);
count++;
}
while((count < max) && (sp < sp_end))
{
u32 *addr;
/* Try and find all the pointers on the stack, then see if they are within range
and point to a valid return address. There is possible false positives with this
but tbh it is better than nothing */
addr = (u32*) *sp;
/* Check that the address could possibly be a valid ra address */
if((addr >= (ELF_START + 2)) && (addr < ELF_END))
{
if(IS_CALL(addr[-2]))
{
if((count == 1) && (addr == ra) && (!recurse))
{
/* Set recurse to 1 so any further calls from ra will be caught */
/* This is not ideal, but it is to try and prevent the more likely case
of the first ra being found on the stack when first parsing */
recurse = 1;
}
else
{
trace[count].func_addr = CALL_ADDR(addr[-2]);
trace[count].call_addr = (u32) (&addr[-2]);
count++;
}
}
}
sp++;
}
return count;
}
int pspDebugGetStackTrace2(PspDebugRegBlock *regs, PspDebugStackTrace *trace, int max)
{
u32 *curr_sp;
u32 *sp_end;
u32 *curr_ra;
int curr_thid;
int count = 0;
SceKernelThreadInfo th_stat;
/* This is a real simple (and dirty way) of getting a stack trace, none of this code following shitz */
/* Relies on the system not being totally vaporised on an exception */
if((trace == NULL) || (max < 1))
{
return 0;
}
curr_thid = sceKernelGetThreadId();
if(curr_thid >= 0)
{
memset(&th_stat, 0, sizeof(th_stat));
th_stat.size = sizeof(th_stat);
if(sceKernelReferThreadStatus(curr_thid, &th_stat) >= 0)
{
sp_end = (u32*) ((u8*) th_stat.stack + th_stat.stackSize);
curr_sp = (u32*) (regs->r[29] & ~3);
curr_ra = (u32*) (regs->r[31]);
count = _pspDebugDoStackTrace(curr_sp, sp_end, curr_ra, trace, max);
}
}
return count;
}

291
src/debug/stdio.c Normal file
View File

@@ -0,0 +1,291 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* stdio.c - Debug functions to enable stdout and stderr handlers
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: stdio.c 1925 2006-05-29 14:22:53Z tyranid $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <unistd.h>
#define dbgprintf pspDebugScreenPrintf
static int g_initialised = 0;
static PspDebugInputHandler g_stdin_handler = NULL;
static PspDebugPrintHandler g_stdout_handler = NULL;
static PspDebugPrintHandler g_stderr_handler = NULL;
static SceUID g_in_sema = 0;
/* Probably stdout and stderr should not be guarded by the same mutex */
static SceUID g_out_sema = 0;
static int io_init(PspIoDrvArg *arg)
{
return 0;
}
static int io_exit(PspIoDrvArg *arg)
{
return 0;
}
static int io_open(PspIoDrvFileArg *arg, char *file, int mode, SceMode mask)
{
if((arg->fs_num != STDIN_FILENO) && (arg->fs_num != STDOUT_FILENO) && (arg->fs_num != STDERR_FILENO))
{
return SCE_KERNEL_ERROR_NOFILE;
}
return 0;
}
static int io_close(PspIoDrvFileArg *arg)
{
return 0;
}
static int io_read(PspIoDrvFileArg *arg, char *data, int len)
{
int ret = 0;
(void) sceKernelWaitSema(g_in_sema, 1, 0);
if((arg->fs_num == STDIN_FILENO) && (g_stdin_handler != NULL))
{
ret = g_stdin_handler(data, len);
}
(void) sceKernelSignalSema(g_in_sema, 1);
return ret;
}
static int io_write(PspIoDrvFileArg *arg, const char *data, int len)
{
int ret = 0;
(void) sceKernelWaitSema(g_out_sema, 1, 0);
if((arg->fs_num == STDOUT_FILENO) && (g_stdout_handler != NULL))
{
ret = g_stdout_handler(data, len);
}
else if((arg->fs_num == STDERR_FILENO) && (g_stderr_handler != NULL))
{
ret = g_stderr_handler(data, len);
}
(void) sceKernelSignalSema(g_out_sema, 1);
return ret;
}
static SceOff io_lseek(PspIoDrvFileArg *arg, SceOff ofs, int whence)
{
return 0;
}
static int io_ioctl(PspIoDrvFileArg *arg, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen)
{
return 0;
}
static int io_remove(PspIoDrvFileArg *arg, const char *name)
{
return 0;
}
static int io_mkdir(PspIoDrvFileArg *arg, const char *name, SceMode mode)
{
return 0;
}
static int io_rmdir(PspIoDrvFileArg *arg, const char *name)
{
return 0;
}
static int io_dopen(PspIoDrvFileArg *arg, const char *dir)
{
return 0;
}
static int io_dclose(PspIoDrvFileArg *arg)
{
return 0;
}
static int io_dread(PspIoDrvFileArg *arg, SceIoDirent *dir)
{
return 0;
}
static int io_getstat(PspIoDrvFileArg *arg, const char *file, SceIoStat *stat)
{
return 0;
}
static int io_chstat(PspIoDrvFileArg *arg, const char *file, SceIoStat *stat, int bits)
{
return 0;
}
static int io_rename(PspIoDrvFileArg *arg, const char *oldname, const char *newname)
{
return 0;
}
static int io_chdir(PspIoDrvFileArg *arg, const char *dir)
{
return 0;
}
static int io_mount(PspIoDrvFileArg *arg)
{
return 0;
}
static int io_umount(PspIoDrvFileArg *arg)
{
return 0;
}
static int io_devctl(PspIoDrvFileArg *arg, const char *devname, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen)
{
return 0;
}
static int io_unknown(PspIoDrvFileArg *arg)
{
return 0;
}
static PspIoDrvFuncs tty_funcs =
{
io_init,
io_exit,
io_open,
io_close,
io_read,
io_write,
io_lseek,
io_ioctl,
io_remove,
io_mkdir,
io_rmdir,
io_dopen,
io_dclose,
io_dread,
io_getstat,
io_chstat,
io_rename,
io_chdir,
io_mount,
io_umount,
io_devctl,
io_unknown,
};
static PspIoDrv tty_driver =
{
"tty", 0x10, 0x800, "TTY", &tty_funcs
};
static int tty_init(void)
{
int ret;
(void) sceIoDelDrv("tty"); /* Ignore error */
ret = sceIoAddDrv(&tty_driver);
if(ret < 0)
{
return ret;
}
g_in_sema = sceKernelCreateSema("TtyInMutex", 0, 1, 1, NULL);
if(g_in_sema < 0)
{
return g_in_sema;
}
g_out_sema = sceKernelCreateSema("TtyOutMutex", 0, 1, 1, NULL);
if(g_out_sema < 0)
{
return g_out_sema;
}
ret = sceIoReopen("tty0:", PSP_O_RDONLY, 0777, sceKernelStdin());
if(ret < 0)
{
return ret;
}
ret = sceKernelStdoutReopen("tty1:", PSP_O_WRONLY, 0777);
if(ret < 0)
{
return ret;
}
ret = sceKernelStderrReopen("tty2:", PSP_O_WRONLY, 0777);
if(ret < 0)
{
return ret;
}
g_initialised = 1;
return 0;
}
int pspDebugInstallStdinHandler(PspDebugInputHandler handler)
{
if(g_initialised == 0)
{
int ret;
ret = tty_init();
if(ret < 0)
{
return ret;
}
}
g_stdin_handler = handler;
return 0;
}
int pspDebugInstallStdoutHandler(PspDebugPrintHandler handler)
{
if(g_initialised == 0)
{
int ret;
ret = tty_init();
if(ret < 0)
{
return ret;
}
}
g_stdout_handler = handler;
return 0;
}
int pspDebugInstallStderrHandler(PspDebugPrintHandler handler)
{
if(g_initialised == 0)
{
int ret;
ret = tty_init();
if(ret < 0)
{
return ret;
}
}
g_stderr_handler = handler;
return 0;
}

30
src/display/Makefile.am Normal file
View File

@@ -0,0 +1,30 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
DISPLAY_OBJS = sceDisplay_0000.o sceDisplay_0001.o sceDisplay_0002.o sceDisplay_0003.o sceDisplay_0004.o sceDisplay_0005.o sceDisplay_0006.o sceDisplay_0007.o sceDisplay_0008.o sceDisplay_0009.o sceDisplay_0010.o sceDisplay_0011.o sceDisplay_0012.o sceDisplay_0013.o sceDisplay_0014.o sceDisplay_0015.o sceDisplay_0016.o sceDisplay_0017.o
DISPLAYDRIVER_OBJS = sceDisplay_driver_0000.o sceDisplay_driver_0001.o sceDisplay_driver_0002.o sceDisplay_driver_0003.o sceDisplay_driver_0004.o sceDisplay_driver_0005.o sceDisplay_driver_0006.o sceDisplay_driver_0007.o sceDisplay_driver_0008.o sceDisplay_driver_0009.o sceDisplay_driver_0010.o sceDisplay_driver_0011.o sceDisplay_driver_0012.o sceDisplay_driver_0013.o sceDisplay_driver_0014.o sceDisplay_driver_0015.o sceDisplay_driver_0016.o sceDisplay_driver_0017.o sceDisplay_driver_0018.o sceDisplay_driver_0019.o sceDisplay_driver_0020.o sceDisplay_driver_0021.o sceDisplay_driver_0022.o sceDisplay_driver_0023.o sceDisplay_driver_0024.o sceDisplay_driver_0025.o sceDisplay_driver_0026.o
libpspdisplayincludedir = @PSPSDK_INCLUDEDIR@
libpspdisplayinclude_HEADERS = pspdisplay.h pspdisplay_kernel.h
lib_LIBRARIES = libpspdisplay.a libpspdisplay_driver.a
libpspdisplay_a_SOURCES = sceDisplay.S
libpspdisplay_a_LIBADD = $(DISPLAY_OBJS)
libpspdisplay_driver_a_SOURCES = sceDisplay_driver.S
libpspdisplay_driver_a_LIBADD = $(DISPLAYDRIVER_OBJS)
$(DISPLAY_OBJS): sceDisplay.S
$(COMPILE) -DF_$* $< -c -o $@
$(DISPLAYDRIVER_OBJS): sceDisplay_driver.S
$(COMPILE) -DF_$* $< -c -o $@

129
src/display/pspdisplay.h Normal file
View File

@@ -0,0 +1,129 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspdisplay.h - Prototypes for the sceDisplay library.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
* Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
*
* $Id: pspdisplay.h 2433 2008-10-15 10:00:27Z iwn $
*/
#ifndef __DISPLAY_H__
#define __DISPLAY_H__
#ifdef __cplusplus
extern "C" {
#endif
/** Framebuffer pixel formats. */
enum PspDisplayPixelFormats {
/** 16-bit RGB 5:6:5. */
PSP_DISPLAY_PIXEL_FORMAT_565 = 0,
/** 16-bit RGBA 5:5:5:1. */
PSP_DISPLAY_PIXEL_FORMAT_5551,
/* 16-bit RGBA 4:4:4:4. */
PSP_DISPLAY_PIXEL_FORMAT_4444,
/* 32-bit RGBA 8:8:8:8. */
PSP_DISPLAY_PIXEL_FORMAT_8888
};
enum PspDisplaySetBufSync {
/** Buffer change effective immediately */
PSP_DISPLAY_SETBUF_IMMEDIATE = 0,
/** Buffer change effective next frame */
PSP_DISPLAY_SETBUF_NEXTFRAME = 1
};
enum PspDisplayErrorCodes
{
SCE_DISPLAY_ERROR_OK = 0,
SCE_DISPLAY_ERROR_POINTER = 0x80000103,
SCE_DISPLAY_ERROR_ARGUMENT = 0x80000107
};
/**
* Set display mode
*
* @par Example1:
* @code
* @endcode
*
* @param mode - Display mode, normally 0.
* @param width - Width of screen in pixels.
* @param height - Height of screen in pixels.
*
* @return ???
*/
int sceDisplaySetMode(int mode, int width, int height);
/**
* Get display mode
*
* @param pmode - Pointer to an integer to receive the current mode.
* @param pwidth - Pointer to an integer to receive the current width.
* @param pheight - Pointer to an integer to receive the current height,
*
* @return 0 on success
*/
int sceDisplayGetMode(int *pmode, int *pwidth, int *pheight);
/**
* Display set framebuf
*
* @param topaddr - address of start of framebuffer
* @param bufferwidth - buffer width (must be power of 2)
* @param pixelformat - One of ::PspDisplayPixelFormats.
* @param sync - One of ::PspDisplaySetBufSync
*
* @return 0 on success
*/
int sceDisplaySetFrameBuf(void *topaddr, int bufferwidth, int pixelformat, int sync);
/**
* Get Display Framebuffer information
*
* @param topaddr - pointer to void* to receive address of start of framebuffer
* @param bufferwidth - pointer to int to receive buffer width (must be power of 2)
* @param pixelformat - pointer to int to receive one of ::PspDisplayPixelFormats.
* @param sync - One of ::PspDisplaySetBufSync
*
* @return 0 on success
*/
int sceDisplayGetFrameBuf(void **topaddr, int *bufferwidth, int *pixelformat, int sync);
/**
* Number of vertical blank pulses up to now
*/
unsigned int sceDisplayGetVcount(void);
/**
* Wait for vertical blank start
*/
int sceDisplayWaitVblankStart(void);
/**
* Wait for vertical blank start with callback
*/
int sceDisplayWaitVblankStartCB(void);
/**
* Wait for vertical blank
*/
int sceDisplayWaitVblank(void);
/**
* Wait for vertical blank with callback
*/
int sceDisplayWaitVblankCB(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,72 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspdisplay_kernel.h - Prototypes for the sceDisplay_driver library.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
* Copyright (c) 2007 Alexander Berl <raphael@fx-world.org>
*
* $Id: pspdisplay_kernel.h 2271 2007-07-20 13:08:41Z oopo $
*/
#ifndef __DISPLAYKERNEL_H__
#define __DISPLAYKERNEL_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* Display set framebuf
*
* @param pri - Priority
* @param topaddr - address of start of framebuffer
* @param bufferwidth - buffer width (must be power of 2)
* @param pixelformat - One of ::PspDisplayPixelFormats.
* @param sync - One of ::PspDisplaySetBufSync
*
* @return 0 on success
*/
int sceDisplay_driver_63E22A26(int pri, void *topaddr, int bufferwidth, int pixelformat, int sync);
/**
* Get Display Framebuffer information
*
* @param pri - Priority
* @param topaddr - pointer to void* to receive address of start of framebuffer
* @param bufferwidth - pointer to int to receive buffer width (must be power of 2)
* @param pixelformat - pointer to int to receive one of ::PspDisplayPixelFormats.
* @param sync - One of ::PspDisplaySetBufSync
*
* @return 0 on success
*/
int sceDisplay_driver_5B5AEFAD(int pri, void **topaddr, int *bufferwidth, int *pixelformat, int sync);
/* Define some names to make it nicer */
#define sceDisplaySetFrameBufferInternal sceDisplay_driver_63E22A26
#define sceDisplayGetFrameBufferInternal sceDisplay_driver_5B5AEFAD
/**
* Set Display brightness to a particular level
*
* @param level - Level of the brightness. it goes from 0 (black screen) to 100 (max brightness)
* @param unk1 - Unknown can be 0 or 1 (pass 0)
*/
void sceDisplaySetBrightness(int level,int unk1);
/**
* Get current display brightness
*
* @param level - Pointer to int to receive the current brightness level (0-100)
* @param unk1 - Pointer to int, receives unknown, it's 1 or 0
*/
void sceDisplayGetBrightness(int *level,int *unk1);
#ifdef __cplusplus
}
#endif
#endif

58
src/display/sceDisplay.S Normal file
View File

@@ -0,0 +1,58 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceDisplay_0000
IMPORT_START "sceDisplay",0x40010000
#endif
#ifdef F_sceDisplay_0001
IMPORT_FUNC "sceDisplay",0x0E20F177,sceDisplaySetMode
#endif
#ifdef F_sceDisplay_0002
IMPORT_FUNC "sceDisplay",0xDEA197D4,sceDisplayGetMode
#endif
#ifdef F_sceDisplay_0003
IMPORT_FUNC "sceDisplay",0xDBA6C4C4,sceDisplayGetFramePerSec
#endif
#ifdef F_sceDisplay_0004
IMPORT_FUNC "sceDisplay",0x7ED59BC4,sceDisplaySetHoldMode
#endif
#ifdef F_sceDisplay_0005
IMPORT_FUNC "sceDisplay",0xA544C486,sceDisplaySetResumeMode
#endif
#ifdef F_sceDisplay_0006
IMPORT_FUNC "sceDisplay",0x289D82FE,sceDisplaySetFrameBuf
#endif
#ifdef F_sceDisplay_0007
IMPORT_FUNC "sceDisplay",0xEEDA2E54,sceDisplayGetFrameBuf
#endif
#ifdef F_sceDisplay_0008
IMPORT_FUNC "sceDisplay",0xB4F378FA,sceDisplayIsForeground
#endif
#ifdef F_sceDisplay_0009
IMPORT_FUNC "sceDisplay",0x31C4BAA8,sceDisplay_31C4BAA8
#endif
#ifdef F_sceDisplay_0010
IMPORT_FUNC "sceDisplay",0x9C6EAAD7,sceDisplayGetVcount
#endif
#ifdef F_sceDisplay_0011
IMPORT_FUNC "sceDisplay",0x4D4E10EC,sceDisplayIsVblank
#endif
#ifdef F_sceDisplay_0012
IMPORT_FUNC "sceDisplay",0x36CDFADE,sceDisplayWaitVblank
#endif
#ifdef F_sceDisplay_0013
IMPORT_FUNC "sceDisplay",0x8EB9EC49,sceDisplayWaitVblankCB
#endif
#ifdef F_sceDisplay_0014
IMPORT_FUNC "sceDisplay",0x984C27E7,sceDisplayWaitVblankStart
#endif
#ifdef F_sceDisplay_0015
IMPORT_FUNC "sceDisplay",0x46F186C3,sceDisplayWaitVblankStartCB
#endif
#ifdef F_sceDisplay_0016
IMPORT_FUNC "sceDisplay",0x773DD3A3,sceDisplayGetCurrentHcount
#endif
#ifdef F_sceDisplay_0017
IMPORT_FUNC "sceDisplay",0x210EAB3A,sceDisplayGetAccumulatedHcount
#endif

View File

@@ -0,0 +1,85 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceDisplay_driver_0000
IMPORT_START "sceDisplay_driver",0x00010000
#endif
#ifdef F_sceDisplay_driver_0001
IMPORT_FUNC "sceDisplay_driver",0x206276C2,sceDisplayInit
#endif
#ifdef F_sceDisplay_driver_0002
IMPORT_FUNC "sceDisplay_driver",0x7A10289D,sceDisplayEnd
#endif
#ifdef F_sceDisplay_driver_0003
IMPORT_FUNC "sceDisplay_driver",0x0E20F177,sceDisplaySetMode
#endif
#ifdef F_sceDisplay_driver_0004
IMPORT_FUNC "sceDisplay_driver",0xDEA197D4,sceDisplayGetMode
#endif
#ifdef F_sceDisplay_driver_0005
IMPORT_FUNC "sceDisplay_driver",0xDBA6C4C4,sceDisplayGetFramePerSec
#endif
#ifdef F_sceDisplay_driver_0006
IMPORT_FUNC "sceDisplay_driver",0x432D133F,sceDisplayEnable
#endif
#ifdef F_sceDisplay_driver_0007
IMPORT_FUNC "sceDisplay_driver",0x681EE6A7,sceDisplayDisable
#endif
#ifdef F_sceDisplay_driver_0008
IMPORT_FUNC "sceDisplay_driver",0x7ED59BC4,sceDisplaySetHoldMode
#endif
#ifdef F_sceDisplay_driver_0009
IMPORT_FUNC "sceDisplay_driver",0xA544C486,sceDisplaySetResumeMode
#endif
#ifdef F_sceDisplay_driver_0010
IMPORT_FUNC "sceDisplay_driver",0x63E22A26,sceDisplay_driver_63E22A26
#endif
#ifdef F_sceDisplay_driver_0011
IMPORT_FUNC "sceDisplay_driver",0x5B5AEFAD,sceDisplay_driver_5B5AEFAD
#endif
#ifdef F_sceDisplay_driver_0012
IMPORT_FUNC "sceDisplay_driver",0x289D82FE,sceDisplaySetFrameBuf
#endif
#ifdef F_sceDisplay_driver_0013
IMPORT_FUNC "sceDisplay_driver",0xEEDA2E54,sceDisplayGetFrameBuf
#endif
#ifdef F_sceDisplay_driver_0014
IMPORT_FUNC "sceDisplay_driver",0xB4F378FA,sceDisplayIsForeground
#endif
#ifdef F_sceDisplay_driver_0015
IMPORT_FUNC "sceDisplay_driver",0xAC14F1FF,sceDisplayGetForegroundLevel
#endif
#ifdef F_sceDisplay_driver_0016
IMPORT_FUNC "sceDisplay_driver",0x9E3C6DC6,sceDisplaySetBrightness
#endif
#ifdef F_sceDisplay_driver_0017
IMPORT_FUNC "sceDisplay_driver",0x31C4BAA8,sceDisplayGetBrightness
#endif
#ifdef F_sceDisplay_driver_0018
IMPORT_FUNC "sceDisplay_driver",0x9C6EAAD7,sceDisplayGetVcount
#endif
#ifdef F_sceDisplay_driver_0019
IMPORT_FUNC "sceDisplay_driver",0x4D4E10EC,sceDisplayIsVblank
#endif
#ifdef F_sceDisplay_driver_0020
IMPORT_FUNC "sceDisplay_driver",0x69B53541,sceDisplayGetVblankRest
#endif
#ifdef F_sceDisplay_driver_0021
IMPORT_FUNC "sceDisplay_driver",0x36CDFADE,sceDisplayWaitVblank
#endif
#ifdef F_sceDisplay_driver_0022
IMPORT_FUNC "sceDisplay_driver",0x8EB9EC49,sceDisplayWaitVblankCB
#endif
#ifdef F_sceDisplay_driver_0023
IMPORT_FUNC "sceDisplay_driver",0x984C27E7,sceDisplayWaitVblankStart
#endif
#ifdef F_sceDisplay_driver_0024
IMPORT_FUNC "sceDisplay_driver",0x46F186C3,sceDisplayWaitVblankStartCB
#endif
#ifdef F_sceDisplay_driver_0025
IMPORT_FUNC "sceDisplay_driver",0x773DD3A3,sceDisplayGetCurrentHcount
#endif
#ifdef F_sceDisplay_driver_0026
IMPORT_FUNC "sceDisplay_driver",0x210EAB3A,sceDisplayGetAccumulatedHcount
#endif

18
src/fpu/Makefile.am Normal file
View File

@@ -0,0 +1,18 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/debug -I$(top_srcdir)/src/user
CFLAGS = @PSPSDK_CFLAGS@ -std=gnu99 -Wall -Wmissing-prototypes
CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
libpspfpuincludedir = @PSPSDK_INCLUDEDIR@
libpspfpuinclude_HEADERS = pspfpu.h
lib_LIBRARIES = libpspfpu.a
libpspfpu_a_SOURCES = pspfpu.c
libpspfpu_a_LIBADD =

151
src/fpu/pspfpu.c Normal file
View File

@@ -0,0 +1,151 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspfpu.h - PSP FPU library
*
* Copyright (c) 2006 TyRaNiD (James F.)
*
* $Id: pspfpu.c 1781 2006-02-04 12:53:40Z tyranid $
*/
#include "pspfpu.h"
uint32_t pspfpu_get_fcr31(void)
{
uint32_t ret;
asm(
"cfc1 %0, $31\n"
: "=r"(ret)
);
return ret;
}
void pspfpu_set_fcr31(uint32_t var)
{
asm (
"ctc1 %0, $31\n"
:
: "r"(var)
);
}
void pspfpu_set_roundmode(enum FpuRoundMode mode)
{
uint32_t fcr;
fcr = pspfpu_get_fcr31();
fcr &= ~FPU_RM_MASK;
fcr |= (mode & FPU_RM_MASK);
pspfpu_set_fcr31(fcr);
}
enum FpuRoundMode pspfpu_get_roundmode(void)
{
return pspfpu_get_fcr31() & FPU_RM_MASK;
}
uint32_t pspfpu_get_flags(void)
{
uint32_t fcr;
fcr = pspfpu_get_fcr31();
return (fcr & FPU_FLAGS_MASK) >> FPU_FLAGS_POS;
}
void pspfpu_clear_flags(uint32_t clear)
{
uint32_t fcr;
clear &= 0x1F;
fcr = pspfpu_get_fcr31();
fcr &= ~(clear << FPU_FLAGS_POS);
pspfpu_set_fcr31(fcr);
}
uint32_t pspfpu_get_enable(void)
{
uint32_t fcr;
fcr = pspfpu_get_fcr31();
return (fcr & FPU_ENABLE_MASK) >> FPU_ENABLE_POS;
}
void pspfpu_set_enable(uint32_t enable)
{
uint32_t fcr;
enable &= 0x1F;
fcr = pspfpu_get_fcr31() & ~FPU_ENABLE_MASK;
fcr |= enable << FPU_ENABLE_POS;
pspfpu_set_fcr31(fcr);
}
uint32_t pspfpu_get_cause(void)
{
uint32_t fcr;
fcr = pspfpu_get_fcr31();
return (fcr & FPU_CAUSE_MASK) >> FPU_CAUSE_POS;
}
void pspfpu_clear_cause(uint32_t clear)
{
uint32_t fcr;
clear &= 0x3F;
fcr = pspfpu_get_fcr31();
fcr &= ~(clear << FPU_CAUSE_POS);
pspfpu_set_fcr31(fcr);
}
uint32_t pspfpu_get_fs(void)
{
uint32_t fcr;
fcr = pspfpu_get_fcr31();
return (fcr & FPU_FS_MASK) >> FPU_FS_POS;
}
void pspfpu_set_fs(uint32_t fs)
{
uint32_t fcr;
fcr = pspfpu_get_fcr31();
fcr &= ~FPU_FS_MASK;
fcr |= ((fs & 1) << FPU_FS_POS);
pspfpu_set_fcr31(fcr);
}
uint32_t pspfpu_get_condbits(void)
{
uint32_t fcr;
uint32_t cond;
fcr = pspfpu_get_fcr31();
cond = (fcr & FPU_CC0_MASK) >> FPU_CC0_POS;
cond |= (fcr & FPU_CC17_MASK) >> (FPU_CC17_POS-1);
return cond;
}
void pspfpu_clear_condbits(uint32_t clear)
{
uint32_t fcr;
clear &= 0xFF;
fcr = pspfpu_get_fcr31();
fcr &= ~((clear & 1) << FPU_CC0_POS);
fcr &= ~((clear & 0xFE) << (FPU_CC17_POS-1));
pspfpu_set_fcr31(fcr);
}

185
src/fpu/pspfpu.h Normal file
View File

@@ -0,0 +1,185 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspfpu.h - Prototypes for the FPU library
*
* Copyright (c) 2006 TyRaNiD (James F.)
*
* $Id: pspfpu.h 1782 2006-02-04 12:57:05Z tyranid $
*/
#ifndef __PSPFPU_H__
#define __PSPFPU_H__
#include <stdint.h>
/* Note the bit settings in here come from an NEC MIPSv4 document,
* they seem sensible.
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Enumeration for FPU rounding modes */
enum FpuRoundMode
{
/** Round to nearest representable value */
FPU_RN = 0,
/** Round towards zero */
FPU_RZ = 1,
/** Round towards plus infinity */
FPU_RP = 2,
/** Round towards minus infinity */
FPU_RM = 3,
};
/** Mask value for rounding mode */
#define FPU_RM_MASK 0x03
/** Enumeration for FPU exceptions */
enum FpuExceptions
{
/** Inexact operation exception */
FPU_EXCEPTION_INEXACT = 0x01,
/** Underflow exception */
FPU_EXCEPTION_UNDERFLOW = 0x02,
/** Overflow exception */
FPU_EXCEPTION_OVERFLOW = 0x04,
/** Division by zero exception */
FPU_EXCEPTION_DIVBYZERO = 0x08,
/** Invalid operation exception */
FPU_EXCEPTION_INVALIDOP = 0x10,
/** Unimplemented operation exception (only supported in the cause bits) */
FPU_EXCEPTION_UNIMPOP = 0x20,
/** All exceptions */
FPU_EXCEPTION_ALL = 0x3F
};
/** Bit position of the flag bits */
#define FPU_FLAGS_POS 2
/** Bit position of the enable bits */
#define FPU_ENABLE_POS 7
/** Bit position of the cause bits */
#define FPU_CAUSE_POS 12
/** Bit position of the cc0 bit */
#define FPU_CC0_POS 23
/** Bit position of the fs bit */
#define FPU_FS_POS 24
/** Bit position of the cc1->7 bits */
#define FPU_CC17_POS 25
#define FPU_FLAGS_MASK (0x1F << FPU_FLAGS_POS)
#define FPU_ENABLE_MASK (0x1F << FPU_ENABLE_POS)
#define FPU_CAUSE_MASK (0x3F << FPU_CAUSE_POS)
#define FPU_CC0_MASK (1 << FPU_CC0_POS)
#define FPU_FS_MASK (1 << FPU_FS_POS)
#define FPU_CC17_MASK (0x7F << FPU_CC17_POS)
/**
* Get the current value of the control/status register
*
* @return The value of the control/status register
*/
uint32_t pspfpu_get_fcr31(void);
/**
* Set the current value of the control/status register
*
* @param var - The value to set.
*/
void pspfpu_set_fcr31(uint32_t var);
/**
* Set the current round mode
*
* @param mode - The rounding mode to set, one of ::FpuRoundMode
*/
void pspfpu_set_roundmode(enum FpuRoundMode mode);
/**
* Get the current round mode
*
* @return The round mode, one of ::FpuRoundMode
*/
enum FpuRoundMode pspfpu_get_roundmode(void);
/**
* Get the exception flags (set when an exception occurs but
* the actual exception bit is not enabled)
*
* @return Bitmask of the flags, zero or more of ::FpuExceptions
*/
uint32_t pspfpu_get_flags(void);
/**
* Clear the flags bits
*
* @param clear - Bitmask of the bits to clear, one or more of ::FpuExceptions
*/
void pspfpu_clear_flags(uint32_t clear);
/**
* Get the exception enable flags
*
* @return Bitmask of the flags, zero or more of ::FpuExceptions
*/
uint32_t pspfpu_get_enable(void);
/**
* Set the enable flags bits
*
* @param enable - Bitmask of exceptions to enable, zero or more of ::FpuExceptions
*/
void pspfpu_set_enable(uint32_t enable);
/**
* Get the cause bits (only useful if you installed your own exception handler)
*
* @return Bitmask of flags, zero or more of ::FpuExceptions
*/
uint32_t pspfpu_get_cause(void);
/**
* Clear the cause bits
*
* @param clear - Bitmask of the bits to clear, one or more of ::FpuExceptions
*
*/
void pspfpu_clear_cause(uint32_t clear);
/**
* Get the current value of the FS bit (if FS is 0 then an exception occurs with
* denormalized values, if 1 then they are rewritten as 0.
*
* @return The current state of the FS bit (0 or 1)
*/
uint32_t pspfpu_get_fs(void);
/**
* Set the FS bit
*
* @param fs - 0 or 1 to unset or set fs
*/
void pspfpu_set_fs(uint32_t fs);
/**
* Get the condition flags (8 bits)
*
* @return The current condition flags
*/
uint32_t pspfpu_get_condbits(void);
/**
* Clear the condition bits
*
* @param clear - Bitmask of the bits to clear
*/
void pspfpu_clear_condbits(uint32_t clear);
#ifdef __cplusplus
}
#endif
#endif /* __PSPFPU_H__ */

30
src/ge/Makefile.am Normal file
View File

@@ -0,0 +1,30 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
GE_OBJS = sceGe_user_0000.o sceGe_user_0001.o sceGe_user_0002.o sceGe_user_0003.o sceGe_user_0004.o sceGe_user_0005.o sceGe_user_0006.o sceGe_user_0007.o sceGe_user_0008.o sceGe_user_0009.o sceGe_user_0010.o sceGe_user_0011.o sceGe_user_0012.o sceGe_user_0013.o sceGe_user_0014.o sceGe_user_0015.o sceGe_user_0016.o sceGe_user_0017.o
GEDRIVER_OBJS = sceGe_driver_0000.o sceGe_driver_0001.o sceGe_driver_0002.o sceGe_driver_0003.o sceGe_driver_0004.o sceGe_driver_0005.o sceGe_driver_0006.o sceGe_driver_0007.o sceGe_driver_0008.o sceGe_driver_0009.o sceGe_driver_0010.o sceGe_driver_0011.o sceGe_driver_0012.o sceGe_driver_0013.o sceGe_driver_0014.o sceGe_driver_0015.o sceGe_driver_0016.o sceGe_driver_0017.o sceGe_driver_0018.o sceGe_driver_0019.o sceGe_driver_0020.o sceGe_driver_0021.o sceGe_driver_0022.o sceGe_driver_0023.o
libpspgeincludedir = @PSPSDK_INCLUDEDIR@
libpspgeinclude_HEADERS = pspge.h
lib_LIBRARIES = libpspge.a libpspge_driver.a
libpspge_a_SOURCES = sceGe_user.S
libpspge_a_LIBADD = $(GE_OBJS)
libpspge_driver_a_SOURCES = sceGe_driver.S
libpspge_driver_a_LIBADD = $(GEDRIVER_OBJS)
$(GE_OBJS): sceGe_user.S
$(COMPILE) -DF_$* $< -c -o $@
$(GEDRIVER_OBJS): sceGe_driver.S
$(COMPILE) -DF_$* $< -c -o $@

213
src/ge/pspge.h Normal file
View File

@@ -0,0 +1,213 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspge.h - Prototypes for the sceGe library.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: pspge.h 2433 2008-10-15 10:00:27Z iwn $
*/
#ifndef __GE_H__
#define __GE_H__
#ifdef __cplusplus
extern "C" {
#endif
/** Stores the state of the GE. */
typedef struct PspGeContext {
unsigned int context[512];
} PspGeContext;
/** Typedef for a GE callback */
typedef void (*PspGeCallback)(int id, void *arg);
/** Structure to hold the callback data */
typedef struct PspGeCallbackData
{
/** GE callback for the signal interrupt */
PspGeCallback signal_func;
/** GE callback argument for signal interrupt */
void *signal_arg;
/** GE callback for the finish interrupt */
PspGeCallback finish_func;
/** GE callback argument for finish interrupt */
void *finish_arg;
} PspGeCallbackData;
typedef struct PspGeListArgs
{
unsigned int size;
PspGeContext* context;
} PspGeListArgs;
/**
* Get the size of VRAM.
*
* @return The size of VRAM (in bytes).
*/
unsigned int sceGeEdramGetSize(void);
/**
* Get the address of VRAM.
*
* @return A pointer to the base of VRAM.
*/
void * sceGeEdramGetAddr(void);
/**
* Retrive the current value of a GE command.
*
* @param cmd - The GE command register to retrieve.
*
* @return The value of the GE command.
*/
unsigned int sceGeGetCmd(int cmd);
/** GE matrix types. */
typedef enum PspGeMatrixTypes {
/** Bone matrices. */
PSP_GE_MATRIX_BONE0 = 0,
PSP_GE_MATRIX_BONE1,
PSP_GE_MATRIX_BONE2,
PSP_GE_MATRIX_BONE3,
PSP_GE_MATRIX_BONE4,
PSP_GE_MATRIX_BONE5,
PSP_GE_MATRIX_BONE6,
PSP_GE_MATRIX_BONE7,
/** World matrix. */
PSP_GE_MATRIX_WORLD,
/** View matrix. */
PSP_GE_MATRIX_VIEW,
/** Projection matrix. */
PSP_GE_MATRIX_PROJECTION,
PSP_GE_MATRIX_TEXGEN
} PspGeMatrixTypes;
/**
* Retrieve a matrix of the given type.
*
* @param type - One of ::PspGeMatrixTypes.
* @param matrix - Pointer to a variable to store the matrix.
*
* @return ???
*/
int sceGeGetMtx(int type, void *matrix);
/**
* Save the GE's current state.
*
* @param context - Pointer to a ::PspGeContext.
*
* @return ???
*/
int sceGeSaveContext(PspGeContext *context);
/**
* Restore a previously saved GE context.
*
* @param context - Pointer to a ::PspGeContext.
*
* @return ???
*/
int sceGeRestoreContext(const PspGeContext *context);
/**
* Enqueue a display list at the tail of the GE display list queue.
*
* @param list - The head of the list to queue.
* @param stall - The stall address.
* If NULL then no stall address set and the list is transferred immediately.
* @param cbid - ID of the callback set by calling sceGeSetCallback
* @param arg - Structure containing GE context buffer address
*
* @return The ID of the queue.
*/
int sceGeListEnQueue(const void *list, void *stall, int cbid, PspGeListArgs *arg);
/**
* Enqueue a display list at the head of the GE display list queue.
*
* @param list - The head of the list to queue.
* @param stall - The stall address.
* If NULL then no stall address set and the list is transferred immediately.
* @param cbid - ID of the callback set by calling sceGeSetCallback
* @param arg - Structure containing GE context buffer address
*
* @return The ID of the queue.
*/
int sceGeListEnQueueHead(const void *list, void *stall, int cbid, PspGeListArgs *arg);
/**
* Cancel a queued or running list.
*
* @param qid - The ID of the queue.
*
* @return ???
*/
int sceGeListDeQueue(int qid);
/**
* Update the stall address for the specified queue.
*
* @param qid - The ID of the queue.
* @param stall - The stall address to update
*
* @return Unknown. Probably 0 if successful.
*/
int sceGeListUpdateStallAddr(int qid, void *stall);
/** Wait condition for ::sceGeListSync() and ::sceGeDrawSync(). */
typedef enum PspGeSyncType {
PSP_GE_LIST_DONE = 0,
PSP_GE_LIST_QUEUED,
PSP_GE_LIST_DRAWING_DONE,
PSP_GE_LIST_STALL_REACHED,
PSP_GE_LIST_CANCEL_DONE
} PspGeSyncType;
/**
* Wait for syncronisation of a list.
*
* @param qid - The queue ID of the list to sync.
* @param syncType - Specifies the condition to wait on. One of ::PspGeSyncType.
*
* @return ???
*/
int sceGeListSync(int qid, int syncType);
/**
* Wait for drawing to complete.
*
* @param syncType - Specifies the condition to wait on. One of ::PspGeSyncType.
*
* @return ???
*/
int sceGeDrawSync(int syncType);
/**
* Register callback handlers for the the Ge
*
* @param cb - Configured callback data structure
* @return The callback ID, < 0 on error
*/
int sceGeSetCallback(PspGeCallbackData *cb);
/**
* Unregister the callback handlers
*
* @param cbid - The ID of the callbacks from sceGeSetCallback
* @return < 0 on error
*/
int sceGeUnsetCallback(int cbid);
#ifdef __cplusplus
}
#endif
#endif /* __GE_H__ */

76
src/ge/sceGe_driver.S Normal file
View File

@@ -0,0 +1,76 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceGe_driver_0000
IMPORT_START "sceGe_driver",0x00010000
#endif
#ifdef F_sceGe_driver_0001
IMPORT_FUNC "sceGe_driver",0x71FCD1D6,sceGeInit
#endif
#ifdef F_sceGe_driver_0002
IMPORT_FUNC "sceGe_driver",0x9F2C2948,sceGeEnd
#endif
#ifdef F_sceGe_driver_0003
IMPORT_FUNC "sceGe_driver",0x8F185DF7,sceGeEdramInit
#endif
#ifdef F_sceGe_driver_0004
IMPORT_FUNC "sceGe_driver",0x1F6752AD,sceGeEdramGetSize
#endif
#ifdef F_sceGe_driver_0005
IMPORT_FUNC "sceGe_driver",0xE47E40E4,sceGeEdramGetAddr
#endif
#ifdef F_sceGe_driver_0006
IMPORT_FUNC "sceGe_driver",0xB77905EA,sceGeEdramSetAddrTranslation
#endif
#ifdef F_sceGe_driver_0007
IMPORT_FUNC "sceGe_driver",0xB415364D,sceGeGetReg
#endif
#ifdef F_sceGe_driver_0008
IMPORT_FUNC "sceGe_driver",0xDC93CFEF,sceGeGetCmd
#endif
#ifdef F_sceGe_driver_0009
IMPORT_FUNC "sceGe_driver",0x57C8945B,sceGeGetMtx
#endif
#ifdef F_sceGe_driver_0010
IMPORT_FUNC "sceGe_driver",0x438A385A,sceGeSaveContext
#endif
#ifdef F_sceGe_driver_0011
IMPORT_FUNC "sceGe_driver",0x0BF608FB,sceGeRestoreContext
#endif
#ifdef F_sceGe_driver_0012
IMPORT_FUNC "sceGe_driver",0xAB49E76A,sceGeListEnQueue
#endif
#ifdef F_sceGe_driver_0013
IMPORT_FUNC "sceGe_driver",0x1C0D95A6,sceGeListEnQueueHead
#endif
#ifdef F_sceGe_driver_0014
IMPORT_FUNC "sceGe_driver",0x5FB86AB0,sceGeListDeQueue
#endif
#ifdef F_sceGe_driver_0015
IMPORT_FUNC "sceGe_driver",0xE0D68148,sceGeListUpdateStallAddr
#endif
#ifdef F_sceGe_driver_0016
IMPORT_FUNC "sceGe_driver",0x03444EB4,sceGeListSync
#endif
#ifdef F_sceGe_driver_0017
IMPORT_FUNC "sceGe_driver",0xB287BD61,sceGeDrawSync
#endif
#ifdef F_sceGe_driver_0018
IMPORT_FUNC "sceGe_driver",0xB448EC0D,sceGeBreak
#endif
#ifdef F_sceGe_driver_0019
IMPORT_FUNC "sceGe_driver",0x4C06E472,sceGeContinue
#endif
#ifdef F_sceGe_driver_0020
IMPORT_FUNC "sceGe_driver",0xA4FC06A4,sceGeSetCallback
#endif
#ifdef F_sceGe_driver_0021
IMPORT_FUNC "sceGe_driver",0x05DB22CE,sceGeUnsetCallback
#endif
#ifdef F_sceGe_driver_0022
IMPORT_FUNC "sceGe_driver",0x9DA4A75F,sceGe_driver_9DA4A75F
#endif
#ifdef F_sceGe_driver_0023
IMPORT_FUNC "sceGe_driver",0x114E1745,sceGe_driver_114E1745
#endif

58
src/ge/sceGe_user.S Normal file
View File

@@ -0,0 +1,58 @@
.set noreorder
#include "pspimport.s"
#ifdef F_sceGe_user_0000
IMPORT_START "sceGe_user",0x40010000
#endif
#ifdef F_sceGe_user_0001
IMPORT_FUNC "sceGe_user",0x1F6752AD,sceGeEdramGetSize
#endif
#ifdef F_sceGe_user_0002
IMPORT_FUNC "sceGe_user",0xE47E40E4,sceGeEdramGetAddr
#endif
#ifdef F_sceGe_user_0003
IMPORT_FUNC "sceGe_user",0xB77905EA,sceGeEdramSetAddrTranslation
#endif
#ifdef F_sceGe_user_0004
IMPORT_FUNC "sceGe_user",0xDC93CFEF,sceGeGetCmd
#endif
#ifdef F_sceGe_user_0005
IMPORT_FUNC "sceGe_user",0x57C8945B,sceGeGetMtx
#endif
#ifdef F_sceGe_user_0006
IMPORT_FUNC "sceGe_user",0x438A385A,sceGeSaveContext
#endif
#ifdef F_sceGe_user_0007
IMPORT_FUNC "sceGe_user",0x0BF608FB,sceGeRestoreContext
#endif
#ifdef F_sceGe_user_0008
IMPORT_FUNC "sceGe_user",0xAB49E76A,sceGeListEnQueue
#endif
#ifdef F_sceGe_user_0009
IMPORT_FUNC "sceGe_user",0x1C0D95A6,sceGeListEnQueueHead
#endif
#ifdef F_sceGe_user_0010
IMPORT_FUNC "sceGe_user",0x5FB86AB0,sceGeListDeQueue
#endif
#ifdef F_sceGe_user_0011
IMPORT_FUNC "sceGe_user",0xE0D68148,sceGeListUpdateStallAddr
#endif
#ifdef F_sceGe_user_0012
IMPORT_FUNC "sceGe_user",0x03444EB4,sceGeListSync
#endif
#ifdef F_sceGe_user_0013
IMPORT_FUNC "sceGe_user",0xB287BD61,sceGeDrawSync
#endif
#ifdef F_sceGe_user_0014
IMPORT_FUNC "sceGe_user",0xB448EC0D,sceGeBreak
#endif
#ifdef F_sceGe_user_0015
IMPORT_FUNC "sceGe_user",0x4C06E472,sceGeContinue
#endif
#ifdef F_sceGe_user_0016
IMPORT_FUNC "sceGe_user",0xA4FC06A4,sceGeSetCallback
#endif
#ifdef F_sceGe_user_0017
IMPORT_FUNC "sceGe_user",0x05DB22CE,sceGeUnsetCallback
#endif

36
src/gu/Makefile.am Normal file
View File

@@ -0,0 +1,36 @@
libdir = @PSPSDK_LIBDIR@
CC = @PSP_CC@
CCAS = $(CC)
AR = @PSP_AR@
RANLIB = @PSP_RANLIB@
INCLUDES = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel -I$(top_srcdir)/src/display -I$(top_srcdir)/src/ge -I$(top_srcdir)/src/user -I$(top_srcdir)/src/debug
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS) $(INCLUDES)
libpspguincludedir = @PSPSDK_INCLUDEDIR@
libpspguinclude_HEADERS = pspgu.h
lib_LIBRARIES = libpspgu.a
noinst_HEADERS = guInternal.h
libpspgu_a_SOURCES = callbackFin.c callbackSig.c guInternal.c resetValues.c sceGuAlphaFunc.c sceGuAmbient.c \
sceGuAmbientColor.c sceGuBeginObject.c sceGuBlendFunc.c sceGuBoneMatrix.c sceGuBreak.c sceGuCallList.c \
sceGuCallMode.c sceGuCheckList.c sceGuClear.c sceGuClearColor.c sceGuClearDepth.c sceGuClearStencil.c \
sceGuClutLoad.c sceGuClutMode.c sceGuColor.c sceGuColorFunc.c sceGuColorMaterial.c sceGuContinue.c \
sceGuCopyImage.c sceGuDepthBuffer.c sceGuDepthFunc.c sceGuDepthMask.c sceGuDepthOffset.c \
sceGuDepthRange.c sceGuDisable.c sceGuDispBuffer.c sceGuDisplay.c sceGuDrawArray.c sceGuDrawArrayN.c \
sceGuDrawBezier.c sceGuDrawBuffer.c sceGuDrawBufferList.c sceGuDrawSpline.c sceGuEnable.c sceGuEndObject.c \
sceGuFinish.c sceGuFog.c sceGuFrontFace.c sceGuGetAllStatus.c sceGuGetMemory.c sceGuGetStatus.c sceGuInit.c \
sceGuLight.c sceGuLightAtt.c sceGuLightColor.c sceGuLightMode.c sceGuLightSpot.c sceGuLogicalOp.c \
sceGuMaterial.c sceGuModelColor.c sceGuMorphWeight.c sceGuOffset.c sceGuPatchDivide.c sceGuPatchFrontFace.c \
sceGuPatchPrim.c sceGuPixelMask.c sceGuScissor.c sceGuSendCommandf.c sceGuSendCommandi.c sceGuSendList.c \
sceGuSetAllStatus.c sceGuSetCallback.c sceGuSetDither.c sceGuSetMatrix.c sceGuSetStatus.c sceGuShadeModel.c \
sceGuSignal.c sceGuSpecular.c sceGuStart.c sceGuStencilFunc.c sceGuStencilOp.c \
sceGuSwapBuffers.c sceGuSync.c sceGuTerm.c sceGuTexEnvColor.c sceGuTexFilter.c sceGuTexFlush.c sceGuTexFunc.c \
sceGuTexImage.c sceGuTexLevelMode.c sceGuTexMapMode.c sceGuTexMode.c sceGuTexOffset.c sceGuTexProjMapMode.c \
sceGuTexScale.c sceGuTexSlope.c sceGuTexSync.c sceGuTexWrap.c sceGuViewport.c sendCommand.c

16
src/gu/callbackFin.c Normal file
View File

@@ -0,0 +1,16 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void callbackFin(int id, void* arg)
{
GuSettings* settings = (GuSettings*)arg;
if (settings->fin)
settings->fin(id & 0xffff);
}

23
src/gu/callbackSig.c Normal file
View File

@@ -0,0 +1,23 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
#include <pspkernel.h>
void callbackSig(int id, void* arg)
{
GuSettings* settings = (GuSettings*)arg;
settings->signal_history[(settings->signal_offset++) & 15] = id & 0xffff;
if (settings->sig)
settings->sig(id & 0xffff);
sceKernelSetEventFlag(settings->kernel_event_flag,1);
}

999
src/gu/doc/commands.txt Normal file
View File

@@ -0,0 +1,999 @@
GE Command Format:
Each command word is divided into two parts, a 8-bit command and a 24-bit
argument. The command is in the upper part of the word, and the argument
in the lower. The argument can be either integer of a special kind of float
that the GE supports (described below).
GE Floats:
Floats processed in the command-stream are 24 bits instead of 32 that are
used by the CPU. Conversion from 32 to 24 bits is done by shifting the
value down 8 bits, losing the least significant bits of the mantissa.
Pointers:
Some pointers use a shared register when loading addresses called BASE. This
register must be written BEFORE you write to the designated register. All
these registers are marked with (BASE) after the summary.
Other pointers only use 28 bits of information, and their top bits are
referred to as the '4 most significant bits' in pointer, which reflects
bits 24-27, not 28-31 which could perhaps be believed from common
terminology.
Enabling Registers:
Any command or bit that has 'Enable' in the name implies that setting the
first bit (or the bit itself) enables the feature, and no ON/OFF-states
are documented.
DISCLAIMER: Names and bitsets are all derived from reverse engineering,
available PS2 documentation and educated guesses. Nothing has been derived
using illegal methods.
Dec Hex Name Description
--- --- ---- -----------
0 00 NOP No Operation
1 01 VADDR Vertex Address (BASE)
0-23: 24 least significant bits of pointer
2 02 IADDR Index Address (BASE)
0-23: 24 least significant bits of pointer
4 04 PRIM Primitive Kick
0-15: Number of vertices to kick (0-65535)
16-18: Primitive Type
000: Points
001: Lines
010: Line Strips
011: Triangles
100: Triangle Strips
101: Triangle Fans
110: Sprites (2D Rectangles)
5 05 BEZIER Bezier Patch Kick
0-7: U Count
8-15: V Count
6 06 SPLINE Spline Surface Kick
0-7: U Count
8-15: V Count
16-17: U Edges
00: Close/Close
01: Open/Close
10: Close/Open
11: Open/Open
18-19: V Edges
00: Close/Close
01: Open/Close
10: Close/Open
11: Open/Open
7 07 BBOX Bounding Box
0-15: Number of vertices to test for conditional rendering (0-65535)
8 08 JUMP Jump To New Address (BASE)
0-23: 24 least significant bits of pointer
9 09 BJUMP Conditional Jump (BASE)
0-23: 24 least significant bits of pointer
10 0A CALL Call Address (BASE)
0-23: 24 least significant bits of pointer
11 0B RET Return From Call
12 0C END Stop execution
14 0E SIGNAL Raise Signal Interrupt
0-15: Argument to pass to signal handler
16-23: Signal index to trigger
15 0F FINISH Complete rendering
0-15: Finish signal argument
16 10 BASE Base Address Register
16-20: 4 most significant bits for address (28 bits total)
18 12 VTYPE Vertex Type
0-1: Texture Format (2 values ST/UV)
00: Not present in vertex
01: 8-bit fixed
10: 16-bit fixed
11: 32-bit floats
2-4: Color Format (1 value)
000: Not present in vertex
100: 16-bit BGR-5650
101: 16-bit ABGR-5551
110: 16-bit ABGR-4444
111: 32-bit ABGR-8888
5-6: Normal Format (3 values XYZ)
00: Not present in vertex
01: 8-bit fixed
10: 16-bit fixed
11: 32-bit floats
7-8: Position Format (3 values XYZ)
00: Not present in vertex
01: 8-bit fixed
10: 16-bit fixed
11: 32-bit floats
9-10: Weight Format
00: Not present in vertex
01: 8-bit fixed
10: 16-bit fixed
11: 32-bit floats
11-12: Index Format
00: Not using indices
01: 8-bit
10: 16-bit
14-16: Number of weights (Skinning)
000-111: 1-8 weights
18-20: Number of vertices (Morphing)
000-111: 1-8 vertices
23: Bypass Transform Pipeline
0: Transformed Coordinates
1: Raw Coordinates
19 13 ??? Offset Address (BASE)
20 14 ??? Origin Address (BASE)
21 15 REGION1 Draw Region Start
0-9: X Start
10-19: Y Start
22 16 REGION2 Draw Region End
0-9: X End ((X + Width)-1)
10-19: Y End ((Y+Height)-1)
23 17 LTE Lighting Enable
24 18 LTE0 Light Enable 0
25 19 LTE1 Light Enable 1
26 1A LTE2 Light Enable 2
27 1B LTE3 Light Enable 3
28 1C CPE Clip Plane Enable
29 1D BCE Backface Culling Enable
30 1E TME Texture Mapping Enable
31 1F FGE Fog Enable
32 20 DTE Dither Enable
33 21 ABE Alpha Blend Enable
34 22 ATE Alpha Test Enable
35 23 ZTE Depth Test Enable
36 24 STE Stencil Test Enable
37 25 AAE Anti Aliasing Enable
38 26 PCE Patch Cull Enable
39 27 CTE Color Test Enable
40 28 LOE Logical Operation Enable
42 2A BOFS Bone Matrix Offset
0-23: Bone Matrix Offset
Offset is in values, so each matrix is offset by 3*4 values
43 2B BONE Bone Matrix Upload
0-23: Matrix Value (GE Float)
Write 3x4 times to upload full bone matrix
44 2C MW0 Morph Weight 0
0-23: Morph Value (GE Float)
45 2D MW1 Morph Weight 1
0-23: Morph Value (GE Float)
46 2E MW2 Morph Weight 2
0-23: Morph Value (GE Float)
47 2F MW3 Morph Weight 3
0-23: Morph Value (GE Float)
48 30 MW4 Morph Weight 4
0-23: Morph Value (GE Float)
49 31 MW5 Morph Weight 5
0-23: Morph Value (GE Float)
50 32 MW6 Morph Weight 6
0-23: Morph Value (GE Float)
51 33 MW7 Morph Weight 7
0-23: Morph Value (GE Float)
54 36 PSUB Patch Subdivision
0-7: S Subdivision
8-15: T Subdivision
55 37 PPRIM Patch Primitive
0-1:
00: Triangles
01: Lines
10: Points
56 38 PFACE Patch Front Face
0:
0: Clockwise
1: Counter-Clockwise
58 3A WMS World Matrix Select
59 3B WORLD World Matrix Upload
0-23: Matrix Value (GE Float)
Write 3*4 values for complete matrix
60 3C VMS View Matrix Select
61 3D VIEW View Matrix Upload
0-23: Matrix Value (GE Float)
Write 3*4 values for complete matrix
62 3E PMS Projection Matrix Select
63 3F PROJ Projection Matrix Upload
0-23: Matrix Value (GE Float)
Write 4*4 values for complete matrix
64 40 TMS Texture Matrix Select
65 41 TMATRIX Texture Matrix Upload
0-23: Matrix Value
Write 3*4 values for complete matrix
66 42 XSCALE Viewport Width Scale
0-23: Scale Value (GE Float)
67 43 YSCALE Viewport Height Scale
0-23: Scale Value (GE Float)
68 44 ZSCALE Depth Scale
0-23: Scale Value (GE Float)
69 45 XPOS Viewport X Position
0-23: Offset Value (GE Float)
70 46 YPOS Viewport Y Position
0-23: Offset Value (GE Float)
71 47 ZPOS Depth Position
0-23: Offset Value (GE Float)
72 48 USCALE Texture U Scale
0-23: Scale Value (GE Float)
73 49 USCALE Texture V Scale
0-23: Scale Value (GE Float)
74 4A OFFSET Texture U Offset
0-23: Offset Value (GE Float)
75 4B OFFSET Texture V Offset
0-23: Offset Value (GE Float)
76 4C OFFSETX Viewport X Offset
0-23: X Offset (12.4 fixed)
77 4D OFFSETY Viewport Y Offset
0-23: Y Offset (12.4 fixed)
80 50 SHADE Shade Model
0: Shading type
0: Flat
1: Smooth
81 51 RNORM Reverse Face Normals Enable
83 53 CMAT Color Material
0-2: Material flags (OR together)
001: Ambient
010: Diffuse
100: Specular
84 54 EMC Emissive Model Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
85 55 AMC Ambient Model Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
86 56 DMC Diffuse Model Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
87 57 SMC Specular Model Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
88 58 AMA Ambient Model Alpha
0-7: Alpha Component
91 5B SPOW Specular Power
0-23: Power (GE Float)
92 5C ALC Ambient Light Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
93 5D ALA Amibient Light Alpha
0-7: Alpha Component
94 5E LMODE Light Model
0: Lighting model
0: Single color
1: Separate specular color
95 5F LT0 Light Type 0
0-1: Light Components
00: Ambient & Diffuse
01: Diffuse & Specular
10: Unknown (diffuse color, affected by specular power)
8-9: Light Type
00: Directional Light
01: Point Light
10: Spot Light
96 60 LT1 Light Type 1
0-1: Light Components
00: Ambient & Diffuse
01: Diffuse & Specular
10: Unknown (diffuse color, affected by specular power)
8-9: Light Type
00: Directional Light
01: Point Light
10: Spot Light
97 61 LT2 Light Type 2
0-1: Light Components
00: Ambient & Diffuse
01: Diffuse & Specular
10: Unknown (diffuse color, affected by specular power)
8-9: Light Type
00: Directional Light
01: Point Light
10: Spot Light
98 62 LT3 Light Type 3
0-1: Light Components
00: Ambient & Diffuse
01: Diffuse & Specular
10: Unknown (diffuse color, affected by specular power)
8-9: Light Type
00: Directional Light
01: Point Light
10: Spot Light
99 63 LXP0 Light X Position 0
0-23: Vector Component (GE Float)
100 64 LYP0 Light Y Position 0
0-23: Vector Component (GE Float)
101 65 LZP0 Light Z Position 0
0-23: Vector Component (GE Float)
102 66 LXP1 Light X Position 1
0-23: Vector Component (GE Float)
103 67 LYP1 Light Y Position 1
0-23: Vector Component (GE Float)
104 68 LZP1 Light Z Position 1
0-23: Vector Component (GE Float)
105 69 LXP2 Light X Position 2
0-23: Vector Component (GE Float)
106 6A LYP2 Light Y Position 2
0-23: Vector Component (GE Float)
107 6B LZP2 Light Z Position 2
0-23: Vector Component (GE Float)
108 6C LXP3 Light X Position 3
0-23: Vector Component (GE Float)
109 6D LYP3 Light Y Position 3
0-23: Vector Component (GE Float)
110 6E LZP3 Light Z Position 3
0-23: Vector Component (GE Float)
111 6F LXD0 Light X Direction 0
0-23: Vector Component (GE Float)
112 70 LYD0 Light Y Direction 0
0-23: Vector Component (GE Float)
113 71 LZD0 Light Z Direction 0
0-23: Vector Component (GE Float)
114 72 LXD0 Light X Direction 1
0-23: Vector Component (GE Float)
115 73 LYD0 Light Y Direction 1
0-23: Vector Component (GE Float)
116 74 LZD0 Light Z Direction 1
0-23: Vector Component (GE Float)
117 75 LXD0 Light X Direction 2
0-23: Vector Component (GE Float)
118 76 LYD0 Light Y Direction 2
0-23: Vector Component (GE Float)
119 77 LZD0 Light Z Direction 2
0-23: Vector Component (GE Float)
120 78 LXD0 Light X Direction 3
0-23: Vector Component (GE Float)
121 79 LYD0 Light Y Direction 3
0-23: Vector Component (GE Float)
122 7A LZD0 Light Z Direction 3
0-23: Vector Component (GE Float)
123 7B LCA0 Light Constant Attenuation 0
0-23: Attenuation Factor (GE Float)
124 7C LLA0 Light Linear Attenuation 0
0-23: Attenuation Factor (GE Float)
125 7D LQA0 Light Quadratic Attenuation 0
0-23: Attenuation Factor (GE Float)
126 7E LCA1 Light Constant Attenuation 1
0-23: Attenuation Factor (GE Float)
127 7F LLA1 Light Linear Attenuation 1
0-23: Attenuation Factor (GE Float)
128 80 LQA1 Light Quadratic Attenuation 1
0-23: Attenuation Factor (GE Float)
129 81 LCA2 Light Constant Attenuation 2
0-23: Attenuation Factor (GE Float)
130 82 LLA2 Light Linear Attenuation 2
0-23: Attenuation Factor (GE Float)
131 83 LQA2 Light Quadratic Attenuation 2
0-23: Attenuation Factor (GE Float)
132 84 LCA3 Light Constant Attenuation 3
0-23: Attenuation Factor (GE Float)
133 85 LLA3 Light Linear Attenuation 3
0-23: Attenuation Factor (GE Float)
134 86 LQA3 Light Quadratic Attenuation 3
0-23: Attenuation Factor (GE Float)
135 87 ??? Spot light 0 exponent
0-23: Spotlight exponent
136 88 ??? Spot light 1 exponent
0-23: Spotlight exponent
137 89 ??? Spot light 2 exponent
0-23: Spotlight exponent
139 8A ??? Spot light 3 exponent
0-23: Spotlight exponent
139 8B ??? Spot light 0 cutoff
0-23: Spotlight cutoff angle (cosine of angle)
140 8C ??? Spot light 1 cutoff
0-23: Spotlight cutoff angle (cosine of angle)
141 8D ??? Spot light 2 cutoff
0-23: Spotlight cutoff angle (cosine of angle)
142 8E ??? Spot light 3 cutoff
0-23: Spotlight cutoff angle (cosine of angle)
143 8F ALC0 Ambient Light Color 0
0-7: Red Component
8-15: Green Component
16-23: Blue Component
144 90 DLC0 Diffuse Light Color 0
0-7: Red Component
8-15: Green Component
16-23: Blue Component
145 91 SLC0 Specular Light Color 0
0-7: Red Component
8-15: Green Component
16-23: Blue Component
146 92 ALC1 Ambient Light Color 1
0-7: Red Component
8-15: Green Component
16-23: Blue Component
147 93 DLC1 Diffuse Light Color 1
0-7: Red Component
8-15: Green Component
16-23: Blue Component
148 94 SLC1 Specular Light Color 1
0-7: Red Component
8-15: Green Component
16-23: Blue Component
149 95 ALC2 Ambient Light Color 2
0-7: Red Component
8-15: Green Component
16-23: Blue Component
150 96 DLC2 Diffuse Light Color 2
0-7: Red Component
8-15: Green Component
16-23: Blue Component
151 97 SLC2 Specular Light Color 2
0-7: Red Component
8-15: Green Component
16-23: Blue Component
152 98 ALC3 Ambient Light Color 3
0-7: Red Component
8-15: Green Component
16-23: Blue Component
153 99 DLC3 Diffuse Light Color 3
0-7: Red Component
8-15: Green Component
16-23: Blue Component
154 9A SLC3 Specular Light Color 3
0-7: Red Component
8-15: Green Component
16-23: Blue Component
155 9B FFACE Front Face Culling Order
0: Culling Order
0: Clockwise primitives are visible
1: Counter-clockwise primitives are visible
156 9C FBP Frame Buffer Pointer
0-23: 24 least significant bits of pointer (see FBW)
157 9D FBW Frame Buffer Width
0-15: Buffer width in pixels
16-23: 8 most significant bits of pointer (see FBP)
158 9E ZBP Depth Buffer Pointer
0-23: 24 least significant bits of pointer (see ZBW)
159 9F ZBW Depth Buffer Width
0-15: Buffer width in pixels
16-23: 8 most significant bits of pointer (see ZBP)
160 A0 TBP0 Texture Buffer Pointer 0
0-23: 24 least significant bits of pointer (see TBW0)
161 A1 TBP1 Texture Buffer Pointer 1
0-23: 24 least significant bits of pointer (see TBW1)
162 A2 TBP2 Texture Buffer Pointer 2
0-23: 24 least significant bits of pointer (see TBW2)
163 A3 TBP3 Texture Buffer Pointer 3
0-23: 24 least significant bits of pointer (see TBW3)
164 A4 TBP4 Texture Buffer Pointer 4
0-23: 24 least significant bits of pointer (see TBW4)
165 A5 TBP5 Texture Buffer Pointer 5
0-23: 24 least significant bits of pointer (see TBW5)
166 A6 TBP6 Texture Buffer Pointer 6
0-23: 24 least significant bits of pointer (see TBW6)
167 A7 TBP7 Texture Buffer Pointer 7
0-23: 24 least significant bits of pointer (see TBW7)
168 A8 TBW0 Texture Buffer Width 0
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP0)
169 A9 TBW1 Texture Buffer Width 1
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP1)
170 AA TBW2 Texture Buffer Width 2
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP2)
171 AB TBW3 Texture Buffer Width 3
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP3)
172 AC TBW4 Texture Buffer Width 4
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP4)
173 AD TBW5 Texture Buffer Width 5
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP5)
174 AE TBW6 Texture Buffer Width 6
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP6)
175 AF TBW7 Texture Buffer Width 7
0-15: Buffer width in pixels
16-20: 4 most significant bits of pointer (see TBP7)
176 B0 CBP CLUT Buffer Pointer
0-23: 24 least significant bits of pointer (see CBPH)
177 B1 CBPH CLUT Buffer Pointer H
16-20: 4 most significant bits of pointer (see CBP)
178 B2 TRXSBP Transmission Source Buffer Pointer
0-23: 24 least significant bits of pointer (see TRXSBW)
179 B3 TRXSBW Transmission Source Buffer Width
0-15: Source Buffer Width
16-23: 8 most significant bits of pointer (see TRXSBP)
180 B4 TRXDBP Transmission Destination Buffer Pointer
0-23: 24 least significant bits of pointer (see TRXDBW)
181 B5 TRXDBW Transmission Destination Buffer Width
0-15: Destination Buffer Width
16-23: 8 most significant bits of pointer (see TRXDBP)
184 B8 TSIZE0 Texture Size Level 0
0-7: Width = 2^TW
8-15: Height = 2^TH
185 B9 TSIZE1 Texture Size Level 1
0-7: Width = 2^TW
8-15: Height = 2^TH
186 BA TSIZE2 Texture Size Level 2
0-7: Width = 2^TW
8-15: Height = 2^TH
187 BB TSIZE3 Texture Size Level 3
0-7: Width = 2^TW
8-15: Height = 2^TH
188 BC TSIZE4 Texture Size Level 4
0-7: Width = 2^TW
8-15: Height = 2^TH
189 BD TSIZE5 Texture Size Level 5
0-7: Width = 2^TW
8-15: Height = 2^TH
190 BE TSIZE6 Texture Size Level 6
0-7: Width = 2^TW
8-15: Height = 2^TH
191 BF TSIZE7 Texture Size Level 7
0-7: Width = 2^TW
8-15: Height = 2^TH
192 C0 TMAP Texture Projection Map Mode + Texture Map Mode
0-1: Texture Map Mode
00: Texture Coordinates (UV)
01: Texture Matrix
10: Environment Map
8-9: Texture Projection Map Mode
00: Position
01: Texture Coordinates
10: Normalized Normal
11: Normal
193 C1 Texture Environment Map Matrix
0-1: 1st Column for matrix
8-9: 2nd column for matrix
194 C2 TMODE Texture Mode
0: Swizzle Enable
8-15: ???
16-20: Maximum mipmap level
195 C3 TPSM Texture Pixel Storage Mode
0-23: Pixel Storage Mode
0: 16-bit BGR 5650
1: 16-bit ABGR 5551
2: 16-bit ABGR 4444
3: 32-bit ABGR 8888
4: 4-bit indexed
5: 8-bit indexed
6: 16-bit indexed
7: 32-bit indexed
8: DXT1
9: DXT3
10: DXT5
196 C4 CLOAD CLUT Load
0-23: Number of colors divided by 8
197 C5 CMODE CLUT Mode
0-1: CLUT Pixel Format
00: 16-bit BGR 5650
01: 16-bit ABGR 5551
10: 16-bit ABGR 4444
11: 32-bit ABGR 8888
2-7: ???
8-15: mask
16-23: ???
198 C6 TFLT Texture Filter
0-2: Minifying filter
8-10: Magnifying filter
000: Nearest
001: Linear
100: Nearest; Mipmap Nearest
101: Linear; Mipmap Nearest
110: Nearest; Mipmap Linear
111: Linear; Mipmap Linear
199 C7 TWRAP Texture Wrapping
0: U Wrap Mode
8: V Wrap Mode
0: Repeat
1: Clamp
200 C8 TBIAS Texture Level Bias (???)
0-15: ???
16-23: Mipmap bias (signed)
201 C9 TFUNC Texture Function
0-2: Texture Effect
000: Modulate
001: Decal
010: Blend
011: Replace
100: Add
8: Texture Color Component
0: Texture alpha is ignored
1: Texture alpha is read
16: Fragment Double Enable
0: Fragment color is untouched
1: Fragment color is doubled
202 CA TEC Texture Environment Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
203 CB TFLUSH Texture Flush
Invalidate texture cache on texture change
204 CC TSYNC Texture Sync
Sync with texture transfer (see TRXKICK)
205 CD FFAR Fog Far (???)
206 CE FDIST Fog Range
0-23: Range (GE Float)
207 CF FCOL Fog Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
208 D0 TSLOPE Texture Slope
0-23: Slope (GE Float)
210 D2 PSM Frame Buffer Pixel Storage Mode
0-1: Pixel Storage Mode
00: 16-bit BGR 5650
01: 16-bit ABGR 5551
10: 16-bit ABGR 4444
11: 32-bit ABGR 8888
211 D3 CLEAR Clear Flags
0: Clear enable
8-11: Clear flags (OR together)
001: Clear Color Buffer
010: Clear Stencil/Alpha Buffer
100: Clear Depth Buffer
212 D4 SCISSOR1 Scissor Region Start
0-9: X Start
10-19: Y Start
213 D5 SCISSOR2 Scissor Region End
0-9: X End
10-19: Y End
214 D6 NEARZ Near Depth Range
0-15: Depth Value
215 D7 FARZ Far Depth Range
0-15: Depth Value
216 D8 CTST Color Test Function
0-1: Color Function
00: Never pass pixel
01: Always pass pixel
10: Pass pixel if color matches
11: Pass pixel if color differs
217 D9 CREF Color Reference
0-23: Color Reference Value
218 DA CMSK Color Mask
0-23: Color Mask
219 DB ATST Alpha Test
0-2: Alpha Test Function
000: Never pass pixel
001: Always pass pixel
010: Pass pixel if match
011: Pass pixel if difference
100: Pass pixel if less
101: Pass pixel if less or equal
110: Pass pixel if greater
111: Pass pixel if greater or equal
8-15: Alpha Reference Value
16-23: Alpha Mask
220 DC STST Stencil Test
0-2: Stencil Function
000: Never pass stencil test
001: Always pass stencil test
010: Pass test if match
011: Pass test if difference
100: Pass test if less
101: Pass test if less or equal
110: Pass test if greater
111: Pass test if greater or equal
8-15: Stencil Reference Value
16-23: Stencil Mask
221 DD SOP Stencil Operations
0-3: Pass Op
8-11: Fail Op
16-18: Zfail Op
000: Keep stencil value
001: Zero stencil value
010: Replace stencil value
011: Invert stencil value
100: Increment stencil value
101: Decrement stencil value
222 DE ZTST Depth Test Function
0-2: Function
000: Never pass pixel
001: Always pass pixel
010: Pass pixel when depth is equal
011: Pass pixel when depth is not equal
100: Pass pixel when depth is less
101: Pass pixel when depth is less or equal
110: Pass pixel when depth is greater
111: Pass pixel when depth is greater or equal
223 DF ALPHA Alpha Blend
0-3: Blend Operation
000: Add
001: Subtract
010: Reverse Subtract
011: Minimum Value
100: Maximum Value
101: Absolute Value
4-7: Source Function
8-11: Destination Function
0000: Source Color
0001: One Minus Source Color
0010: Source Alpha
0011: One Minus Source Alpha
0100: Destination Color
0101: One Minus Destination Color
0110: Destination Alpha
0111: One Minus Destination Alpha
1010: Fix
224 E0 SFIX Source Fix Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
225 E1 DFIX Destination Fix Color
0-7: Red Component
8-15: Green Component
16-23: Blue Component
226 E2 DTH0 Dither Matrix Row 0
0-3: Column 0
4-7: Column 1
8-11: Column 2
12-15: Column 3
227 E3 DTH1 Dither Matrix Row 1
0-3: Column 0
4-7: Column 1
8-11: Column 2
12-15: Column 3
228 E4 DTH2 Dither Matrix Row 2
0-3: Column 0
4-7: Column 1
8-11: Column 2
12-15: Column 3
229 E5 DTH3 Dither Matrix Row 3
0-3: Column 0
4-7: Column 1
8-11: Column 2
12-15: Column 3
230 E6 LOP Logical Operation
0-3: Logic Op
0000: Clear
0001: And
0010: Reverse And
0011: Copy
0100: Inverted And
0101: No Operation
0110: Exclusive Or
0111: Or
1000: Negated Or
1001: Equivalence
1010: Inverted
1011: Reverse Or
1100: Inverted Copy
1101: Inverted Or
1110: Negated And
1111: Set
231 E7 ZMSK Depth Mask
0-15: Depth Write Mask
232 E8 PMSKC Pixel Mask Color
0-7: Red Write Mask
8-15: Green Write Mask
16-23: Blue Write Mask
233 E9 PMSKA Pixel Mask Alpha
0-7: Alpha Write Mask
234 EA TRXKICK Transmission Kick
0:
0: 16-bit texel size
1: 32-bit texel size
235 EB TRXSPOS Transfer Source Position
0-9: X Position
10-19: Y Position
236 EC TRXDPOS Transfer Destination Position
0-9: X Position
10-19: Y Position
237 EE TRXSIZE Transfer Size
0-9: Width = Transfer Width-1
10-19: Height = Transfer Height-1

55
src/gu/guInternal.c Normal file
View File

@@ -0,0 +1,55 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
unsigned int gu_current_frame;
GuContext gu_contexts[3];
int ge_list_executed[2];
void* ge_edram_address;
GuSettings gu_settings;
GuDisplayList* gu_list;
int gu_curr_context;
int gu_init;
int gu_display_on;
int gu_call_mode;
int gu_states;
GuDrawBuffer gu_draw_buffer;
unsigned int* gu_object_stack[32];
int gu_object_stack_depth;
GuLightSettings light_settings[4] =
{
{
0x18, 0x5f, 0x63, 0x64,
0x65, 0x6f, 0x70, 0x71,
0x8f, 0x90, 0x91, 0x7b,
0x7c, 0x7d, 0x87, 0x8b
},
{
0x19, 0x60, 0x66, 0x67,
0x68, 0x72, 0x73, 0x74,
0x92, 0x93, 0x94, 0x7e,
0x7f, 0x80, 0x88, 0x8c
},
{
0x1a, 0x61, 0x69, 0x6a,
0x6b, 0x75, 0x76, 0x77,
0x95, 0x96, 0x97, 0x81,
0x82, 0x83, 0x89, 0x8d
},
{
0x1b, 0x62, 0x6c, 0x6d,
0x6e, 0x78, 0x79, 0x7a,
0x98, 0x99, 0x9a, 0x84,
0x85, 0x86, 0x8a, 0x8e
}
};

125
src/gu/guInternal.h Normal file
View File

@@ -0,0 +1,125 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#ifndef __guInternal_h__
#define __guInternal_h__
#include "pspgu.h"
typedef void (*GuCallback)(int);
typedef struct
{
GuCallback sig;
GuCallback fin;
short signal_history[16];
int signal_offset;
int kernel_event_flag;
int ge_callback_id;
GuSwapBuffersCallback swapBuffersCallback;
int swapBuffersBehaviour;
} GuSettings;
typedef struct
{
unsigned int* start;
unsigned int* current;
int parent_context;
} GuDisplayList;
typedef struct
{
GuDisplayList list;
int scissor_enable;
int scissor_start[2];
int scissor_end[2];
int near_plane;
int far_plane;
int depth_offset;
int fragment_2x;
int texture_function;
int texture_proj_map_mode;
int texture_map_mode;
int sprite_mode[4];
unsigned int clear_color;
unsigned int clear_stencil;
unsigned int clear_depth;
int texture_mode;
} GuContext;
typedef struct
{
int pixel_size;
int frame_width;
void* frame_buffer;
void* disp_buffer;
void* depth_buffer;
int depth_width;
int width;
int height;
} GuDrawBuffer;
typedef struct
{
/* row 0 */
unsigned char enable; // Light enable
unsigned char type; // Light type
unsigned char xpos; // X position
unsigned char ypos; // Y position
/* row 1 */
unsigned char zpos; // Z position
unsigned char xdir; // X direction
unsigned char ydir; // Y direction
unsigned char zdir; // Z direction
/* row 2 */
unsigned char ambient; // Ambient color
unsigned char diffuse; // Diffuse color
unsigned char specular; // Specular color
unsigned char constant; // Constant attenuation
/* row 3 */
unsigned char linear; // Linear attenuation
unsigned char quadratic;// Quadratic attenuation
unsigned char exponent; // Light exponent
unsigned char cutoff; // Light cutoff
} GuLightSettings;
extern unsigned int gu_current_frame;
extern GuContext gu_contexts[3];
extern int ge_list_executed[2];
extern void* ge_edram_address;
extern GuSettings gu_settings;
extern GuDisplayList* gu_list;
extern int gu_curr_context;
extern int gu_init;
extern int gu_display_on;
extern int gu_call_mode;
extern int gu_states;
extern GuDrawBuffer gu_draw_buffer;
extern unsigned int* gu_object_stack[];
extern int gu_object_stack_depth;
extern GuLightSettings light_settings[4];
void sendCommandi(int cmd, int argument);
void sendCommandiStall(int cmd, int argument);
void sendCommandf(int cmd, float argument);
void callbackSig(int id, void* arg);
void callbackFin(int id, void* arg);
void resetValues();
#endif

1487
src/gu/pspgu.h Normal file

File diff suppressed because it is too large Load Diff

63
src/gu/resetValues.c Normal file
View File

@@ -0,0 +1,63 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void resetValues()
{
unsigned int i;
gu_init = 0;
gu_states = 0;
gu_current_frame = 0;
gu_object_stack_depth = 0;
gu_display_on = 0;
gu_call_mode = 0;
gu_draw_buffer.pixel_size = 1;
gu_draw_buffer.frame_width = 0;
gu_draw_buffer.frame_buffer = 0;
gu_draw_buffer.disp_buffer = 0;
gu_draw_buffer.depth_buffer = 0;
gu_draw_buffer.depth_width = 0;
gu_draw_buffer.width = 480;
gu_draw_buffer.height = 272;
for (i = 0; i < 3; ++i)
{
GuContext* context = &gu_contexts[i];
context->scissor_enable = 0;
context->scissor_start[0] = 0;
context->scissor_start[1] = 0;
context->scissor_end[0] = 0;
context->scissor_end[1] = 0;
context->near_plane = 0;
context->far_plane = 1;
context->depth_offset = 0;
context->fragment_2x = 0;
context->texture_function = 0;
context->texture_proj_map_mode = 0;
context->texture_map_mode = 0;
context->sprite_mode[0] = 0;
context->sprite_mode[1] = 0;
context->sprite_mode[2] = 0;
context->sprite_mode[3] = 0;
context->clear_color = 0;
context->clear_stencil = 0;
context->clear_depth = 0xffff;
context->texture_mode = 0;
}
gu_settings.sig = 0;
gu_settings.fin = 0;
}

15
src/gu/sceGuAlphaFunc.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuAlphaFunc(int a0, int a1, int a2)
{
int arg = a0 | ((a1 & 0xff) << 8) | ((a2 & 0xff) << 16);
sendCommandi(219,arg);
}

15
src/gu/sceGuAmbient.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuAmbient(unsigned int color)
{
sendCommandi(92,(color & 0xffffff));
sendCommandi(93,(color >> 24));
}

View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuAmbientColor(unsigned int color)
{
sendCommandi(85,color & 0xffffff);
sendCommandi(88,color >> 24);
}

37
src/gu/sceGuBeginObject.c Normal file
View File

@@ -0,0 +1,37 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuBeginObject(int vertex_type, int a1, const void* indices, const void* vertices)
{
if (vertex_type)
sendCommandi(18,vertex_type);
if (indices)
{
sendCommandi(16,(((unsigned int)indices) >> 8) & 0xf0000);
sendCommandi(2,((unsigned int)indices) & 0xffffff);
}
if (vertices)
{
sendCommandi(16,(((unsigned int)vertices) >> 8) & 0x0f0000);
sendCommandi(1,((unsigned int)vertices) & 0xffffff);
}
sendCommandi(7,a1);
// store start to new object
gu_object_stack[gu_object_stack_depth++] = gu_list->current;
// dummy commands, overwritten in sceGuEndObject()
sendCommandi(16,0);
sendCommandi(9,0);
}

16
src/gu/sceGuBlendFunc.c Normal file
View File

@@ -0,0 +1,16 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuBlendFunc(int op, int src, int dest, unsigned int srcfix, unsigned int destfix)
{
sendCommandi(223,src | (dest << 4) | (op << 8));
sendCommandi(224,srcfix & 0xffffff);
sendCommandi(225,destfix & 0xffffff);
}

25
src/gu/sceGuBoneMatrix.c Normal file
View File

@@ -0,0 +1,25 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuBoneMatrix(unsigned int index, const ScePspFMatrix4* matrix)
{
unsigned int offset = ((index << 1)+index) << 2; // 3*4 matrix
unsigned int i,j;
const float* fmatrix = (const float*)matrix;
sendCommandi(42,offset);
for (i = 0; i < 4; ++i)
{
for (j = 0; j < 3; ++j)
{
sendCommandf(43,fmatrix[j+(i << 2)]);
}
}
}

15
src/gu/sceGuBreak.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuBreak(int a0)
{
// FIXME
//sceGeBreak(a0,0x527a68);
}

26
src/gu/sceGuCallList.c Normal file
View File

@@ -0,0 +1,26 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuCallList(const void* list)
{
unsigned int list_addr = (unsigned int)list;
if (gu_call_mode == 1)
{
sendCommandi(14,(list_addr >> 16) | 0x110000);
sendCommandi(12,list_addr & 0xffff);
sendCommandiStall(0,0);
}
else
{
sendCommandi(16,(list_addr >> 8) & 0xf0000);
sendCommandiStall(10,list_addr & 0xffffff);
}
}

14
src/gu/sceGuCallMode.c Normal file
View File

@@ -0,0 +1,14 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuCallMode(int mode)
{
gu_call_mode = mode;
}

14
src/gu/sceGuCheckList.c Normal file
View File

@@ -0,0 +1,14 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
int sceGuCheckList(void)
{
return ((int)gu_list->current)-((int)gu_list->start);
}

74
src/gu/sceGuClear.c Normal file
View File

@@ -0,0 +1,74 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuClear(int flags)
{
GuContext* context = &gu_contexts[gu_curr_context];
unsigned int filter;
struct Vertex
{
u32 color;
u16 x,y,z;
u16 pad;
};
switch (gu_draw_buffer.pixel_size)
{
case 0: filter = context->clear_color & 0xffffff; break;
case 1: filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 31); break;
case 2: filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 28); break;
case 3: filter = (context->clear_color & 0xffffff) | (context->clear_stencil << 24); break;
default: filter = 0; break;
}
struct Vertex* vertices;
int count;
if (!(flags & GU_FAST_CLEAR_BIT))
{
vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
count = 2;
vertices[0].color = 0;
vertices[0].x = 0;
vertices[0].y = 0;
vertices[0].z = context->clear_depth;
vertices[1].color = filter;
vertices[1].x = gu_draw_buffer.width;
vertices[1].y = gu_draw_buffer.height;
vertices[1].z = context->clear_depth;
}
else
{
struct Vertex* curr;
unsigned int i;
count = ((gu_draw_buffer.width+63)/64)*2;
vertices = (struct Vertex*)sceGuGetMemory(count * sizeof(struct Vertex));
curr = vertices;
for (i = 0; i < count; ++i, ++curr)
{
unsigned int j,k;
j = i >> 1;
k = (i & 1);
curr->color = filter;
curr->x = (j+k) * 64;
curr->y = k * gu_draw_buffer.height;
curr->z = context->clear_depth;
}
}
sendCommandi(211,((flags & (GU_COLOR_BUFFER_BIT|GU_STENCIL_BUFFER_BIT|GU_DEPTH_BUFFER_BIT)) << 8) | 0x01);
sceGuDrawArray(GU_SPRITES,GU_COLOR_8888|GU_VERTEX_16BIT|GU_TRANSFORM_2D,count,0,vertices);
sendCommandi(211,0);
}

15
src/gu/sceGuClearColor.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuClearColor(unsigned int color)
{
GuContext* context = &gu_contexts[gu_curr_context];
context->clear_color = color;
}

15
src/gu/sceGuClearDepth.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuClearDepth(unsigned int depth)
{
GuContext* context = &gu_contexts[gu_curr_context];
context->clear_depth = depth;
}

View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuClearStencil(unsigned int stencil)
{
GuContext* context = &gu_contexts[gu_curr_context];
context->clear_stencil = stencil;
}

16
src/gu/sceGuClutLoad.c Normal file
View File

@@ -0,0 +1,16 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuClutLoad(int num_blocks, const void* cbp)
{
sendCommandi(176,((unsigned int)cbp) & 0xffffff);
sendCommandi(177,(((unsigned int)cbp) >> 8) & 0xf0000);
sendCommandi(196,num_blocks);
}

15
src/gu/sceGuClutMode.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuClutMode(unsigned int cpsm, unsigned int shift, unsigned int mask, unsigned int a3)
{
unsigned int argument = (cpsm) | (shift << 2) | (mask << 8) | (a3 << 16);
sendCommandi(197,argument);
}

14
src/gu/sceGuColor.c Normal file
View File

@@ -0,0 +1,14 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuColor(unsigned int color)
{
sceGuMaterial(7,color);
}

16
src/gu/sceGuColorFunc.c Normal file
View File

@@ -0,0 +1,16 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuColorFunc(int func, unsigned int color, unsigned int mask)
{
sendCommandi(216,func & 0x03);
sendCommandi(217,color & 0xffffff);
sendCommandi(218,mask);
}

View File

@@ -0,0 +1,14 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuColorMaterial(int a0)
{
sendCommandi(83,a0);
}

15
src/gu/sceGuContinue.c Normal file
View File

@@ -0,0 +1,15 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuContinue(void)
{
// FIXME
//sceGeContinue();
}

21
src/gu/sceGuCopyImage.c Normal file
View File

@@ -0,0 +1,21 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuCopyImage(int psm, int sx, int sy, int width, int height, int srcw, void* src, int dx, int dy, int destw, void* dest)
{
sendCommandi(178,((unsigned int)src) & 0xffffff);
sendCommandi(179,((((unsigned int)src) & 0xff000000) >> 8)|srcw);
sendCommandi(235,(sy << 10)|sx);
sendCommandi(180,((unsigned int)dest) & 0xffffff);
sendCommandi(181,((((unsigned int)dest) & 0xff000000) >> 8)|destw);
sendCommandi(236,(dy << 10)|dx);
sendCommandi(238,((height-1) << 10)|(width-1));
sendCommandi(234,(psm ^ 0x03) ? 0 : 1);
}

20
src/gu/sceGuDepthBuffer.c Normal file
View File

@@ -0,0 +1,20 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuDepthBuffer(void* zbp, int zbw)
{
gu_draw_buffer.depth_buffer = zbp;
if (!gu_draw_buffer.depth_width || (gu_draw_buffer.depth_width != zbw))
gu_draw_buffer.depth_width = zbw;
sendCommandi(158,((unsigned int)zbp) & 0xffffff);
sendCommandi(159,((((unsigned int)zbp) & 0xff000000) >> 8)|zbw);
}

14
src/gu/sceGuDepthFunc.c Normal file
View File

@@ -0,0 +1,14 @@
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* Copyright (c) 2005 Jesper Svennevid
*/
#include "guInternal.h"
void sceGuDepthFunc(int function)
{
sendCommandi(222,function);
}

Some files were not shown because too many files have changed in this diff Show More