News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: How to use syscall/ disc read in psx assembly?  (Read 381 times)

ghostdwl

  • Newbie
  • *
  • Posts: 2
    • View Profile
How to use syscall/ disc read in psx assembly?
« on: August 07, 2018, 07:14:59 am »
I'm editing a psx game, the language of assembler is mips, i need to read data from other files in same ISO/IMG/RAM but i dont know how begin, i searched on google and i found somethings but nothing that can help me in assembly, i need the code in hex/assembly to perform a syscall/disc read, Does anyone know how?

Thanks in advance for the replies and sorry if my english was bad.

Valendian

  • Jr. Member
  • **
  • Posts: 42
    • View Profile
Re: How to use syscall/ disc read in psx assembly?
« Reply #1 on: August 10, 2018, 04:10:38 pm »
You may have better luck tracking the data tables that store the LBA of the file data. That way your files will be treated just like the normal files. You can find these tables by placing breakpoints on CDROM DMA, then back trace the stack to find the original call point.

If this is not possible then you need to read the manual. This documentation is a great place to start:
    https://problemkaputt.de/psx-spx.htm#kernelbios

Quote
A-Functions (Call 00A0h with function number in R9 Register)

A(A5h) - CdReadSector(count,sector,buffer)
Reads <count> sectors, starting at <sector>, and writes data to <buffer>. The read is done in mode=80h (double speed, 800h-bytes per sector). The function waits until all sectors are transferred, and does then return the number of sectors (ie. count), or -1 in case of error.

A(A6h) - CdGetStatus()
Retrieves the cdrom status via CdAsyncGetStatus(dst) (see there for details; especially for cautions on door-open flag). The function waits until the event indicates completion, and does then return the status byte (or -1 in case of error).