Canon PowerShot functions list


Used symbols: Byte, Word, DWord, QWord - 8, 16, 32, 64 bit unsigned numbers; char, int, long - 8, 16, 32 bit signed numbers; Far_Ptr - 32 bit real mode far pointer which consists of Words segment:offset, $\0 - zero terminated string

Following functions are called via its Far_Ptr, input arguments are passed in stack, return values are stored in CPU registers. ASM example of calling:
      PUSH inargs ;push all input argumnts in stack
      LES BX, Func_Far_Ptr ;variable Func_Far_Ptr hold pointer to system function
      CALL DWORD PTR ES:[BX+Sub_Func_Number]
      MOV outargs, AX,BX... ;get return values
How to obtain the Func_Far_Ptr?
      MOV AH, Byte Func_Number
      INT FFh
The pointer is returned in DS:DX registers.
Note: intel CPUs use 'Little Endian' storage, so numbers are stored in memory from LSB to MSB when adressing increase. Example: DWord 12345678h, Memory: 0000h=78h, 0001h=56h, 0002h=45h, 0003h=12h

Subfunctions of system function 01h (system):
subfunction:
00h
description: get system info
input: -
output: Far_Ptr DX:AX SysInfo
note: returns pointer to SysInfo structure.
typedef struct       // system info structure
{
  DWord unknown1;    // ? (A70: 00 00 25 01)
  DWord unknown2;    // ? (A70: A9 C4 BC 0C)
  Byte fwver[4];     // firmware version (A70: 00 00 00 02) - little endian
  DWord unknown3;    // ? (A70: 2C 00 93 D0)
  Byte unknown4;     // ? (A70: 00)
  char idstring[31]; // full camera name $\0
} PS_SYSINFO;
08h
description: keyboard handling
input: ?
output: ?
note: ?
14h
description: critical condition arised?
input: -
output: Word AX
note: returns nonzero if something is going wrong:
1403h - if baterry door has been opened
1405h - if CF door has been opened.
Calling this function also prevent camera auto powerdown which happen if user program is running over about 16 sec (some kind of WatchDog).
BCh
description: get timer ticks since camera turned on
input: Far_Ptr QWord - a place to store 64bit timer value in ms, probably valid only low 32bits
output: -
note: provide 1ms granularity HW speed independent timer
C8h
description: get camera PID
input: -
output: Word AX
note: returns camera Product ID, it can be seen also in upid.ini file or when running s10sh -uD.

Subfunctions of system function 05h (firmware):
subfunction:
64h
description: ?
input: ? Far_Ptr
output: ? Far_Ptr DX:AX
note: ?
68h
description: extract a file from *.FIR package
input: int FirHandle, Far_Ptr char FileId, Far_Ptr char DestPath
output: int AX
note: int FirHandle - handle returned from fileno(fopen(FirFile))
FileId - file ID in FIR, typically in form "fileext" (without dot, e.g. "diskaimg")
DestPath - destination path where to place extracted file (e.g. "D:\diska.img")
returns 0 if OK, -1 if FileID is invalid.

Subfunctions of system function 07h (graphics):
subfunction:
18h
description: set color palette
input: Far_Ptr Word Palette
output: -
note: set color palette which is 32B long array probably consists of 16 Word elements for 16 colors. Palette elements seems to have thys RGBY+ format: ??YYYYYYGBBBGRRR. But I'm not sure of meaning of bits 8,14,15. Here is sample palette from update.exe:
color 0 = 3F00 = 0011111100000000 ;transparent
color 1 = D24F = 1101001001001111
color 2 = C8F2 = 1100100011110010
color 3 = D24F = 1101001001001111
color 4 = C22F = 1100001000101111
color 5 = C21F = 1100001000011111
color 6 = 0600 = 0000011000000000
color 7 = 0000 = 0000000000000000 ;black ?
color 8 = D200 = 1101001000000000
color 9 = E8B1 = 1110100010110001
color A = 1800 = 0001100000000000
color B = D300 = 1101001100000000
color C = 003F = 0000000000111111
color D = DB00 = 1101101100000000
color E = FE00 = 1111111000000000 ;white
color F = C000 = 1100000000000000 ;black
20h
description: copy drawing buffer to screen
input: Word 0
output: -
note: all other graphics commands manipulate with internal drawing buffer. To see the changes on screen you have to call this function. Simple this is double buffering method.
Drawing buffer have resolution 704x481 but LCD only 320x240 Output to LCD is downsampled. High resolution is used for TV-out.
34h
description: clear drawing buffer
input: Word 0, Word BkColor
output: -
note: fill entire buffer with BkColor value.
40h
description: draw filled rectangle
input: Word x, Word y, Word width, Word height, Word 0, Word Color
output: -
note: draw filled rectangle by Color; [x,y] coordinates of top left corner.
78h
description: print text message
input: Far_Ptr TextStruct
output: -
note: prints text message from the structure
typedef struct      // text message structure
{
  Word x;           // x-position [0-703] (but LCD is 320x240)
  Word y;           // y-position [0-480] means 32x10 chars
  char FAR *strptr; // RM pointer to 0-terminated string
  Word bkcolor;     // background color/mode (0=transparent,2=filled,3?,5?)
  Word txtcolor;    // text color (14-white, depends on color palette)
  Word unknown;     // ?, let it be 0
} PS_TEXT_MSG;

Subfunctions of system function 0Ah (menu graphics):
subfunction:
38h
description: draw outlined rectangle
input: Word x, Word y, Word width, Word height, Word 0, Word Color
output: -
note: draw outlined rectangle by Color; [x,y] coordinates of top left corner. Line width is about 20 pixels, quite thick frame...


This description is based on knowledges of Lexeich, RayeR, Gambistics, Cscwidu
HTML formating by RayeR


Updated at 0:54, 6.12.2004