Skip to content

Commit

Permalink
fhi: define file id's
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgaiser committed Sep 10, 2023
1 parent 1afa08f commit 2202631
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions iop/atad_emu/src/ps2atad.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ata_devinfo_t *ata_get_devinfo(int device)

if (device == 0 && dev[0].exists == 0) {
// Initialize
u32 size = fhi_size(1);
u32 size = fhi_size(FHI_FID_ATA0);
if (size > 0) {
M_PRINTF("(%d) size = %d sectors\n", device, size);
dev[0].exists = 1;
Expand Down Expand Up @@ -86,10 +86,10 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir)
M_PRINTF("(%d, 0x%x, %d, %d, %d)\n", device, buf, lba, nsectors, dir);

if (dir == ATA_DIR_WRITE) {
fhi_write(1, buf, lba, nsectors);
fhi_write(FHI_FID_ATA0, buf, lba, nsectors);
return 0;
} else {
fhi_read(1, buf, lba, nsectors);
fhi_read(FHI_FID_ATA0, buf, lba, nsectors);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion iop/cdvdman_emu/src/device-fhi.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void DeviceFSInit(void)
DPRINTF("Waiting for device...\n");

while (1) {
iso_size = fp_fhi_size(0);
iso_size = fp_fhi_size(FHI_FID_CDVD);
if (iso_size > 0)
break;
DelayThread(100 * 1000); // 100ms
Expand Down
6 changes: 6 additions & 0 deletions iop/common/fhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#include <stdint.h>
#include <irx.h>

#define FHI_FID_CDVD 0
#define FHI_FID_ATA0 1
#define FHI_FID_ATA1 2
#define FHI_FID_MC0 3
#define FHI_FID_MC1 4

// Size of the file in SECTORS of 512b
uint32_t fhi_size(int file_handle);
// Read SECTORS from file
Expand Down
2 changes: 1 addition & 1 deletion iop/common/fhi_bdm.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


#define MODULE_SETTINGS_MAGIC 0xf1f2f3f4
#define BDM_MAX_FILES 4
#define BDM_MAX_FILES 5
#define BDM_MAX_FRAGS 64 // 64 * 12bytes = 768bytes

struct fhi_bdm_fragfile
Expand Down
6 changes: 3 additions & 3 deletions iop/mc_emu/src/mcemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ int MceEraseBlock(MemoryCard *mcd, int page)
memset(mcd->dbufp, r, mcd->cspec.PageSize);

for (i = 0; i < mcd->cspec.BlockSize; i++) {
r = fhi_write(mcd->mcnum + 3, mcd->dbufp, page + i, 1);
r = fhi_write(FHI_FID_MC0 + mcd->mcnum, mcd->dbufp, page + i, 1);
if (!r) {
DPRINTF("erase error\n");
return 0;
Expand All @@ -686,7 +686,7 @@ static int do_read(MemoryCard *mcd)
r = (mcd->flags & 0x10) ? 0xFF : 0x0;
memset(mcd->cbufp, r, 0x10);

r = fhi_read(mcd->mcnum + 3, mcd->dbufp, mcd->rpage, 1);
r = fhi_read(FHI_FID_MC0 + mcd->mcnum, mcd->dbufp, mcd->rpage, 1);
if (!r) {
DPRINTF("read error\n");
return 0;
Expand Down Expand Up @@ -788,7 +788,7 @@ int MceWrite(MemoryCard *mcd, void *buf, u32 size)
size = tot_size - size;
mcd->wroff = 0;

r = fhi_write(mcd->mcnum + 3, mcd->dbufp, mcd->wpage, 1);
r = fhi_write(FHI_FID_MC0 + mcd->mcnum, mcd->dbufp, mcd->wpage, 1);
if (!r) {
DPRINTF("write error.\n");
return 0;
Expand Down

0 comments on commit 2202631

Please sign in to comment.