Remove extern global variable from bios_disk.h
This way interface of swapInDisks function is cleaner and we avoid a warning when comparing (previously) signed swap position with an unsigned array size or index. Also, add some documentation to swapInDisks function.
This commit is contained in:
parent
8f81eb199a
commit
c81269eebe
3 changed files with 21 additions and 12 deletions
|
@ -84,12 +84,22 @@ void incrementFDD(void);
|
|||
extern std::array<std::shared_ptr<imageDisk>, MAX_DISK_IMAGES> imageDiskList;
|
||||
extern std::array<std::shared_ptr<imageDisk>, MAX_SWAPPABLE_DISKS> diskSwap;
|
||||
|
||||
extern Bit32s swapPosition;
|
||||
extern Bit16u imgDTASeg; /* Real memory location of temporary DTA pointer for fat image disk access */
|
||||
extern RealPt imgDTAPtr; /* Real memory location of temporary DTA pointer for fat image disk access */
|
||||
extern DOS_DTA *imgDTA;
|
||||
|
||||
void swapInDisks(void);
|
||||
/**
|
||||
* Insert 2 boot disks starting at swap_position into the drives A and B.
|
||||
*
|
||||
* Selected disks are wrapped around, so swapping in the last boot disk
|
||||
* will place the first disk into drive B.
|
||||
*
|
||||
* When there's only 1 disk, it will be placed into both A and B drives.
|
||||
*
|
||||
* When there's no boot disks loaded, this function has no effect.
|
||||
*/
|
||||
void swapInDisks(unsigned int swap_position);
|
||||
|
||||
void swapInNextDisk(void);
|
||||
bool getSwapRequest(void);
|
||||
|
||||
|
|
|
@ -676,9 +676,7 @@ public:
|
|||
i++;
|
||||
}
|
||||
|
||||
swapPosition = 0;
|
||||
|
||||
swapInDisks();
|
||||
swapInDisks(0);
|
||||
|
||||
if (!imageDiskList[drive - 'A']) {
|
||||
WriteOut(MSG_Get("PROGRAM_BOOT_UNABLE"), drive);
|
||||
|
|
|
@ -59,7 +59,8 @@ void CMOS_SetRegister(Bitu regNr, Bit8u val); //For setting equipment word
|
|||
/* 2 floppys and 2 harddrives, max */
|
||||
std::array<std::shared_ptr<imageDisk>, MAX_DISK_IMAGES> imageDiskList;
|
||||
std::array<std::shared_ptr<imageDisk>, MAX_SWAPPABLE_DISKS> diskSwap;
|
||||
Bit32s swapPosition;
|
||||
|
||||
unsigned int swapPosition;
|
||||
|
||||
void updateDPT(void) {
|
||||
Bit32u tmpheads, tmpcyl, tmpsect, tmpsize;
|
||||
|
@ -111,14 +112,14 @@ static size_t disk_array_prefix_size(const std::array<T, N> &images) {
|
|||
return num;
|
||||
}
|
||||
|
||||
void swapInDisks(void) {
|
||||
void swapInDisks(unsigned int swap_position) {
|
||||
const size_t boot_disks_num = disk_array_prefix_size(diskSwap);
|
||||
if (boot_disks_num == 0)
|
||||
return;
|
||||
|
||||
assert(swapPosition < boot_disks_num);
|
||||
const unsigned int pos_1 = swapPosition;
|
||||
const unsigned int pos_2 = (swapPosition + 1) % boot_disks_num;
|
||||
assert(swap_position < boot_disks_num);
|
||||
const unsigned int pos_1 = swap_position;
|
||||
const unsigned int pos_2 = (swap_position + 1) % boot_disks_num;
|
||||
|
||||
imageDiskList[0] = diskSwap[pos_1];
|
||||
LOG_MSG("Loaded disk A from swaplist position %u - \"%s\"",
|
||||
|
@ -145,10 +146,10 @@ void swapInNextDisk(bool pressed) {
|
|||
if (Drives[i]) Drives[i]->EmptyCache();
|
||||
}
|
||||
swapPosition++;
|
||||
if(!diskSwap[swapPosition]) {
|
||||
if (!diskSwap[swapPosition]) {
|
||||
swapPosition = 0;
|
||||
}
|
||||
swapInDisks();
|
||||
swapInDisks(swapPosition);
|
||||
swapping_requested = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue