Work started for the source tracing
[clinton/Virtual-Jaguar-Rx.git] / src / modelsBIOS.cpp
CommitLineData
bc10fc42
JPM
1//
2// modelsBIOS.cpp - Models and BIOS handler
3//
4// by Jean-Paul Mari
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// Who When What
9// --- ---------- -----------------------------------------------------------
10// JPM 09/04/2018 Created this file
11//
12
13
14#include "string.h"
15#include "settings.h"
16#include "jagbios.h"
17#include "jagbios2.h"
18#include "jagcdbios.h"
19#include "jagstub1bios.h"
20#include "jagstub2bios.h"
21#include "memory.h"
22
23
24typedef struct InfosBIOS
25{
26 void *ptrBIOS;
27 size_t sizeBIOS;
28 size_t intBIOS;
29}
30S_InfosBIOS;
31
32
33S_InfosBIOS TabInfosBIOS[] =
34{
35 { NULL, 0, BT_NULL },
36 { jaguarBootROM, 0x20000, BT_K_SERIES },
37 { jaguarBootROM2, 0x20000, BT_M_SERIES },
38 { jaguarDevBootROM1, 0x20000, BT_STUBULATOR_1 },
39 { jaguarDevBootROM2, 0x20000, BT_STUBULATOR_2 }
40};
41
42
43// Select a BIOS
44// A valid default BIOS will be selected in case of no valid BIOS has been requested
45bool SelectBIOS(int indexbios)
46{
47 int IndexBIOS;
48
49#if 1
50 // Get the BIOS selected in the configuration tab
51 if (!indexbios)
52 {
53 indexbios = vjs.biosType;
54 }
55#else
56 indexbios = 10;
57#endif
58
59 // Check if a default BIOS is required
60 if (!indexbios)
61 {
62 // Get default BIOS based on the Jaguar model
63 switch (vjs.jaguarModel)
64 {
65 case JAG_K_SERIES:
66 indexbios = BT_K_SERIES;
67 break;
68
69 case JAG_M_SERIES:
70 indexbios = BT_M_SERIES;
71 break;
72
73 default:
74 break;
75 }
76 }
77
78 // look for the requested BIOS
79 IndexBIOS = (sizeof(TabInfosBIOS) / sizeof(S_InfosBIOS));
80 while (TabInfosBIOS[--IndexBIOS].intBIOS && (TabInfosBIOS[IndexBIOS].intBIOS != indexbios));
81
82 // Put BIOS in memory or return if no BIOS exist (but it should never happen)
83 if (IndexBIOS)
84 {
85 memcpy(jagMemSpace + 0xE00000, TabInfosBIOS[IndexBIOS].ptrBIOS, TabInfosBIOS[IndexBIOS].sizeBIOS);
86 return true;
87 }
88 else
89 {
90 return false;
91 }
92}
93
94
95//
96bool SetBIOS(void)
97{
98 memcpy(jaguarMainRAM, jagMemSpace + 0xE00000, 8);
99 return true;
100}
101