psx.wiki

PDA Library (libmcx)

Provides functions for the PDA when it is inserted into a Memory Card slot.

PDA Library (libmcx)
Librarylibmcx.lib
Header Filelibmcx.h
SDKPsy-Q

Overview

The PDA Library (libmcx) provides access to the functions of the PDA when the PDA is inserted into a Memory Card slot. The PDA works like a Memory Card, runs saved files as ARM7 programs and has an LCD, an LED, a speaker and IR communication. libmcx gets the PDA status, switches the PDA application, accesses the PDA memory, turns the file transfer display on and off and gets and sets the real time clock and the alarm clock.12

A program that uses libmcx links with libmcx.lib and includes libmcx.h.1

This library is part of the run-time library that Sony distributed with the Psy-Q development tools.3

PDA Status

The PDA can be inserted and removed at any time with the power on, and the application must be prepared for this. McxCardType() followed by McxSync() checks for and identifies a PDA or a Memory Card when a card is inserted. A result of McxErrNoCard means that neither is present. McxErrInvalid means that a card is in the connector but communication failed, and McxErrSuccess or McxErrNewCard means that a PDA was found.1

A PDA that has just been swapped is a new card and is handled like a Memory Card. After the card is inserted and the process registration functions have been called, McxSync() returns McxErrNewCard, and the processes then end normally. For McxExecFlag(), however, McxErrNewCard interrupts the processing. The unconfirm flag is then cleared with MemCardAccept() or _card_clear() and the process is registered again.1

Conflicts with Other Libraries

The interrupts of libmcx conflict with libcard and libmcrd, so libmcx cannot be used while their asynchronous functions are pending. Otherwise there is no conflict, since libmcx uses no libcard, libmcrd or card BIOS functions and no HwCARD or SwCARD events.2

The initialization functions of the libraries must be called in a fixed order, or the program may not work correctly. A standard order is PadInit(), InitPAD(), StartPAD(), InitCARD(), StartCARD(), McxStartCom(), PadInitDirect() and PadStartCom(). However, only one of the three sets PadInit(), InitPAD() with StartPAD() and PadInitDirect() with PadStartCom() is used in one program. MemCardInit() and MemCardStart() may replace InitCARD() and StartCARD(), and InitTAP() with StartTAP() or InitGUN() with StartGUN() may replace InitPAD() and StartPAD().2

Hardware

The PDA has the same storage as a Memory Card. It holds 120 KB after format, accessed in 128-byte sectors, and communicates by synchronous serial communication through the controller port. Access is inhibited for 20 ms after a sector is written and continuous reading reaches about 10 KB/sec. It can be swapped with the PlayStation on and is guaranteed for 100,000 writes.4

File Names

The PDA is shared by many applications and is used by common guidelines. Capacity is given in blocks of 64 sectors of 128 bytes, or 8,192 bytes. A file that uses the PDA file header extensions replaces the hyphen of the product code with a capital P, so SLPS-xxxxx becomes SLPSPxxxxx. Otherwise the start-up application does not start it as a PDA application and the file list does not show its animation icons.4

File Header

Each file starts with a standard header, which is either a non-PDA header or a PDA header. The PDA header is upward compatible with the non-PDA header. The non-PDA header is the Memory Card header of libcard. Its CLUT entries are (B[4:0] << 10) | (G[4:0] << 5) | R[4:0], and the Shift-JIS name may not use 0x84bf to 0x889e. The PDA header has the following fields:456

Table 1: PDA file header
Item Size Notes
Magic 2 Always 'SC'
Type 1 0x11, 0x12 or 0x13
Number of blocks 1 Blocks occupied by the file
Document name 64 Shift JIS code
Pad 12 All 0x00
File list icons 2 Number of animation icons (n1)
File type 4 "MCX0", "MCX1" or "CRD0"
Game selection icon pages 1 Number of pages (n2)
User-defined device drivers 1 Number of entries (n3)
Reserved 4 All 0x00
Program starting address 4 ARM7 address
CLUT 32 16 CLUT entries
Memory Card icon images 128 each Set-up screen icons 1 to 3, 16 x 16 x 4 bits
RAM save area 2048 Only for file type "MCX1"
Device driver entry table 128 x n4 8 bytes per driver, n4 = n3 / 16 rounded up
File list icon images 128 x n1 32 x 32 bits each
Game selection icon entry table 128 x n5 8 bytes per page, n5 = n2 / 16 rounded up
Game selection icon images 128 x n6 32 x 32 bits each

The PDA header adds the RAM save area, the device driver table and the icon data after the icon images, and the PDA uses them for its file list and game selection functions.7

File Types

A file of type "MCX0" or "MCX1" is a PDA application that runs as an ARM program, and other files cannot run from the PDA start-up application. An "MCX0" application has no RAM save area and always cold starts. An "MCX1" application has 2048 bytes of RAM save area and may cold start or hot start next time, depending on how it exited. The RAM save area holds the RAM of an interrupted program so that it can restart.78

A file of type "CRD0" holds 32 x 32 icons for animation in the PDA file list without being a PDA application. Its page count, driver count, reserved area and starting address are all 0x00, so it has no RAM save area, driver table or game selection icons.7

The program starting address is an absolute address, with the file header at 0x2000000, and an invalid address is not reported. The icon addresses in the game selection table are absolute addresses on the same base. The device numbers start at 128, and a table of more than 16 devices continues in the next 128 bytes.78

Icons

The PDA uses three types of icon:9

Table 2: Icon types
Item Memory Card set-up screen icon PDA file list icon Game selection icon
Icon size 16 x 16 32 x 32 32 x 32
Color Colors of the CLUT, selected from 32,768 Black and white Black and white
Page count 1 1 n2
Icon count 1 to 3, by the header type n1 n6
Minimum count 1, needed for all files 0 1, for PDA applications

The file list shows the files in the PDA with icon animation. A file uses its file list icons when it has any. A PDA application without them uses page 1 of its game selection icon, and a non-PDA file uses its set-up screen icon converted to 32 x 32 black and white. The icons are updated at the following rates:7910

Table 3: Icon animation update frequency
Icon used Update frequency
Set-up screen icons (2 icons) 2 fps
Set-up screen icons (3 icons) 3 fps
PDA file list icon 6 fps
Game selection icon 30 / speed fps, from the entry table

The game selection function shows only PDA applications and starts the chosen one. Each application may have several pages, each animated with several icons, such as a title page, a summary page and a page of developer names.1011

Using the PDA Functions

McxStartCom() starts the PDA system and enables the PDA interrupts, the Mcx functions access the PDA, and McxStopCom() stops it. All functions that access the PDA are asynchronous. A process registration function such as McxGetTime() reserves the operation, and McxSync() waits for it or checks it, after which the result and the data are valid.11

A PDA application is saved like a Memory Card file between McxShowTrans() and McxHideTrans(), which keep the program out of alternate sectors. McxExecFlag() then marks it as a PDA application in the FAT. The block number is the head member of its DIRENTRY from firstfile() divided by 64.1112

Current Limit

The PlayStation supplies at most 160 mA to all Memory Card connectors together. The IR module, the speaker and the LED of the PDA are therefore enabled from the PlayStation with McxCurrCtrl(). McxAllInfo() returns the devices enabled on every PDA. It checks two connectors, or eight places with Multi Taps. A device is enabled only when the total stays within 160 mA, since more current can make the PlayStation work incorrectly. The currents are the following:12

Table 4: Device current consumption
Device name Current consumption
CPU chip 10 mA
IR module transmitter 70 mA
Speaker 20 mA
LED 10 mA

Functions

In the tables below, Introduced is the run-time library version that added the item.13

libmcx has the following functions:13

Table 5: libmcx functions
Function Introduced Purpose
McxAllInfo 4.4 Get all PDA information (process registration).
McxCardType 4.4 Probe PDA connection status (process registration).
McxCurrCtrl 4.4 Control current capacity (process registration).
McxExecApl 4.4 Execute a PDA application (process registration).
McxExecFlag 4.4 Set the PDA application / data ID flag (process registration).
McxFlashAcs 4.4 Set a PDA application's flash memory write priority (process registration).
McxGetApl 4.4 Obtain the block number where the executing PDA application is stored (process registration).
McxGetMem 4.4 Read the contents of PDA memory (process registration).
McxGetSerial 4.4 Get the PDA’s serial number (process registration).
McxGetTime 4.4 Get the date and time (process registration).
McxGetUIFS 4.4 Get user interface status (process registration).
McxHideTrans 4.4 Hide the "data transfer" display (process registration).
McxReadDev 4.4 Read from the PDA device (process registration).
McxSetLED 4.4 Switch the LED on/off (process registration).
McxSetMem 4.4 Update the contents of PDA memory (process registration).
McxSetTime 4.4 Set the date and time (process registration).
McxSetUIFS 4.4 Set user interface status (process registration).
McxShowTrans 4.4 Show the "data transfer" display (process registration).
McxStartCom 4.4 Start the PDA system.
McxStopCom 4.4 Stop the PDA system.
McxSync 4.4 Confirm the completion of a registered process.
McxWriteDev 4.4 Write to a PDA device (process registration).

References


  1. ^ a b c d Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-3.

  2. ^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-4.

  3. ^ Sony Computer Entertainment Inc. Programmer Tools CD (DTL-S2002), README.TXT. 11/26/96. Section "CD-ROM Contents - Highlights", directories \PSX and \PSYQ.

  4. ^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-5.

  5. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-6.

  6. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-7.

  7. ^ a b c d e Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-8.

  8. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-9.

  9. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-10.

  10. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-11.

  11. ^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-12.

  12. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. Run-Time Library 4.4. January 1999. Page 19-13.

  13. ^ a b Sony Computer Entertainment Inc. Run-Time Library Reference. Run-Time Library 4.4. January 1999. Pages 18-3 to 18-26.

Categories: Psy-Q