summaryrefslogtreecommitdiff
path: root/Loader/loader-psyq.cpp
blob: 204e3e5d3803110f5a28d4b48f187e295bcde96e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "database.h"

union psyq_header_t {
    struct {
        Uint8 id[8];
        Uint32 text, data, pc0, gp0, t_addr, t_size;
        Uint32 d_addr, d_size, b_addr, b_size, s_addr, s_size;
        Uint32 sp, fp, gp, ra, s0;
    };
    Uint8 raw[0x800];
};

static const Uint32 PSX_MAXMEM = 2 * 1024 * 1024;
static const Uint32 BASE_PSX = 0x80000000;
static const Uint32 END_PSX = BASE_PSX + PSX_MAXMEM;

class loader_psyq : public Base {
  public:
    static void load(Cpu * cpu, Handle * input, Database * database) {
        psyq_header_t head;
        Segment * bss = 0, * data = 0;
        
        input->read(&head, sizeof(head));
        
        if (head.t_addr != BASE_PSX)
            bss = database->CreateSegment(cpu, BASE_PSYQ, ABSNUL, 0, head.t_addr - BASE_PSYQ);
        
        data = database->CreateSegment(cpu, head.t_addr, ABSNUL, head.t_size, END_PSX - (head.t_addr + head.t_size));
        data->
        
        database->
    }
};