AltairZ80: Replaced assert() with ASSURE() for error checking at run time
This commit is contained in:
parent
f659574e11
commit
1b7d77e03b
5 changed files with 15 additions and 20 deletions
|
@ -28,7 +28,6 @@
|
|||
*/
|
||||
|
||||
#include "m68k.h"
|
||||
#include "assert.h"
|
||||
#include <ctype.h>
|
||||
#define SWITCHCPU_DEFAULT 0xfd
|
||||
|
||||
|
|
|
@ -131,7 +131,6 @@
|
|||
*/
|
||||
|
||||
#include "altairz80_defs.h"
|
||||
#include <assert.h>
|
||||
|
||||
/* Debug flags */
|
||||
#define IN_MSG (1 << 0)
|
||||
|
@ -406,9 +405,9 @@ static t_stat dsk_attach(UNIT *uptr, CONST char *cptr) {
|
|||
if (r != SCPE_OK) /* error? */
|
||||
return r;
|
||||
|
||||
assert(uptr != NULL);
|
||||
ASSURE(uptr != NULL);
|
||||
thisUnitIndex = find_unit_index(uptr);
|
||||
assert((0 <= thisUnitIndex) && (thisUnitIndex < NUM_OF_DSK));
|
||||
ASSURE((0 <= thisUnitIndex) && (thisUnitIndex < NUM_OF_DSK));
|
||||
|
||||
/* If the file size is close to the mini-disk image size, set the number of
|
||||
tracks to 16, otherwise, 32 sectors per track. */
|
||||
|
@ -423,7 +422,7 @@ static t_stat dsk_attach(UNIT *uptr, CONST char *cptr) {
|
|||
void install_ALTAIRbootROM(void) {
|
||||
const t_bool result = (install_bootrom(bootrom_dsk, BOOTROM_SIZE_DSK, ALTAIR_ROM_LOW, TRUE) ==
|
||||
SCPE_OK);
|
||||
assert(result);
|
||||
ASSURE(result);
|
||||
}
|
||||
|
||||
/* The boot routine modifies the boot ROM in such a way that subsequently
|
||||
|
@ -434,7 +433,7 @@ static t_stat dsk_boot(int32 unitno, DEVICE *dptr) {
|
|||
if (sectors_per_track[unitno] == MINI_DISK_SECT) {
|
||||
const t_bool result = (install_bootrom(alt_bootrom_dsk, BOOTROM_SIZE_DSK,
|
||||
ALTAIR_ROM_LOW, TRUE) == SCPE_OK);
|
||||
assert(result);
|
||||
ASSURE(result);
|
||||
} else {
|
||||
/* check whether we are really modifying an LD A,<> instruction */
|
||||
if ((bootrom_dsk[UNIT_NO_OFFSET_1 - 1] == LDA_INSTRUCTION) &&
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
*/
|
||||
|
||||
#include "m68k.h"
|
||||
#include <assert.h>
|
||||
#include "sim_imd.h"
|
||||
|
||||
/* Debug flags */
|
||||
|
@ -433,10 +432,10 @@ static t_stat hdsk_attach(UNIT *uptr, CONST char *cptr) {
|
|||
if (r != SCPE_OK) /* error? */
|
||||
return r;
|
||||
|
||||
assert(uptr != NULL);
|
||||
ASSURE(uptr != NULL);
|
||||
thisUnitIndex = find_unit_index(uptr);
|
||||
unitChar = '0' + thisUnitIndex;
|
||||
assert((0 <= thisUnitIndex) && (thisUnitIndex < HDSK_NUMBER));
|
||||
ASSURE((0 <= thisUnitIndex) && (thisUnitIndex < HDSK_NUMBER));
|
||||
|
||||
if (is_imd(uptr)) {
|
||||
if ((sim_fsize(uptr -> fileref) == 0) &&
|
||||
|
@ -476,7 +475,7 @@ static t_stat hdsk_attach(UNIT *uptr, CONST char *cptr) {
|
|||
if (uptr -> capac == 0)
|
||||
uptr -> capac = HDSK_CAPACITY;
|
||||
} /* post condition: uptr -> capac > 0 */
|
||||
assert(uptr -> capac);
|
||||
ASSURE(uptr -> capac);
|
||||
|
||||
/* Step 2: Determine format based on disk capacity */
|
||||
assignFormat(uptr);
|
||||
|
@ -502,12 +501,12 @@ static t_stat hdsk_attach(UNIT *uptr, CONST char *cptr) {
|
|||
uptr -> HDSK_SECTORS_PER_TRACK = dpb[uptr -> HDSK_FORMAT_TYPE].spt >> dpb[uptr -> HDSK_FORMAT_TYPE].psh;
|
||||
uptr -> HDSK_SECTOR_SIZE = (128 << dpb[uptr -> HDSK_FORMAT_TYPE].psh);
|
||||
}
|
||||
assert((uptr -> HDSK_SECTORS_PER_TRACK) && (uptr -> HDSK_SECTOR_SIZE) && (uptr -> HDSK_FORMAT_TYPE >= 0));
|
||||
ASSURE((uptr -> HDSK_SECTORS_PER_TRACK) && (uptr -> HDSK_SECTOR_SIZE) && (uptr -> HDSK_FORMAT_TYPE >= 0));
|
||||
|
||||
/* Step 4: Number of tracks is smallest number to accomodate capacity */
|
||||
uptr -> HDSK_NUMBER_OF_TRACKS = (uptr -> capac + uptr -> HDSK_SECTORS_PER_TRACK *
|
||||
uptr -> HDSK_SECTOR_SIZE - 1) / (uptr -> HDSK_SECTORS_PER_TRACK * uptr -> HDSK_SECTOR_SIZE);
|
||||
assert( ( (t_addr) ((uptr -> HDSK_NUMBER_OF_TRACKS - 1) * uptr -> HDSK_SECTORS_PER_TRACK *
|
||||
ASSURE( ( (t_addr) ((uptr -> HDSK_NUMBER_OF_TRACKS - 1) * uptr -> HDSK_SECTORS_PER_TRACK *
|
||||
uptr -> HDSK_SECTOR_SIZE) < uptr -> capac) &&
|
||||
(uptr -> capac <= (t_addr) (uptr -> HDSK_NUMBER_OF_TRACKS *
|
||||
uptr -> HDSK_SECTORS_PER_TRACK * uptr -> HDSK_SECTOR_SIZE) ) );
|
||||
|
@ -524,7 +523,7 @@ static t_stat hdsk_detach(UNIT *uptr) {
|
|||
unitIndex = find_unit_index(uptr);
|
||||
if (unitIndex == -1)
|
||||
return SCPE_IERR;
|
||||
assert((0 <= unitIndex) && (unitIndex < HDSK_NUMBER));
|
||||
ASSURE((0 <= unitIndex) && (unitIndex < HDSK_NUMBER));
|
||||
result = diskClose(&hdsk_imd[unitIndex]);
|
||||
if (result != SCPE_OK) {
|
||||
return result;
|
||||
|
@ -672,7 +671,7 @@ static t_stat hdsk_boot(int32 unitno, DEVICE *dptr) {
|
|||
}
|
||||
installSuccessful = (install_bootrom(bootrom_hdsk, BOOTROM_SIZE_HDSK, HDSK_BOOT_ADDRESS,
|
||||
FALSE) == SCPE_OK);
|
||||
assert(installSuccessful);
|
||||
ASSURE(installSuccessful);
|
||||
*((int32 *) sim_PC -> loc) = HDSK_BOOT_ADDRESS;
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
@ -785,7 +784,7 @@ static int32 doSeek(void) {
|
|||
int32 hostSector;
|
||||
int32 sectorSize;
|
||||
UNIT *uptr = &hdsk_dev.units[selectedDisk];
|
||||
assert(uptr != NULL);
|
||||
ASSURE(uptr != NULL);
|
||||
hostSector = ((dpb[uptr -> HDSK_FORMAT_TYPE].skew == NULL) ?
|
||||
selectedSector : dpb[uptr -> HDSK_FORMAT_TYPE].skew[selectedSector]);
|
||||
sectorSize = ((dpb[uptr -> HDSK_FORMAT_TYPE].physicalSectorSize == 0) ?
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
-------------------------------------------------------------------------------
|
||||
*/
|
||||
#include "altairz80_defs.h"
|
||||
#include <assert.h>
|
||||
|
||||
/** Typedefs & Defines **************************************/
|
||||
#define HDSK_SECTOR_SIZE 256 /* size of sector */
|
||||
|
@ -248,7 +247,7 @@ static int32 bootrom_mhdsk[BOOTROM_SIZE_MHDSK] = {
|
|||
static t_stat mhdsk_boot(int32 unitno, DEVICE *dptr) {
|
||||
const t_bool installSuccessful = (install_bootrom(bootrom_mhdsk, BOOTROM_SIZE_MHDSK,
|
||||
MHDSK_BOOT_ADDRESS, FALSE) == SCPE_OK);
|
||||
assert(installSuccessful);
|
||||
ASSURE(installSuccessful);
|
||||
*((int32 *) sim_PC -> loc) = MHDSK_BOOT_ADDRESS;
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include "sim_sock.h"
|
||||
#include "sim_tmxr.h"
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
uint8 *URLContents(const char *URL, uint32 *length);
|
||||
#ifndef URL_READER_SUPPORT
|
||||
|
@ -750,7 +749,7 @@ static void voidSleep(void) {
|
|||
static int32 sio0sCore(const int32 port, const int32 io, const int32 data) {
|
||||
int32 ch, result;
|
||||
const SIO_PORT_INFO spi = lookupPortInfo(port, &ch);
|
||||
assert(spi.port == port);
|
||||
ASSURE(spi.port == port);
|
||||
pollConnection();
|
||||
if (io == 0) { /* IN */
|
||||
if (sio_unit.u4) { /* attached to a file? */
|
||||
|
@ -820,7 +819,7 @@ int32 sio0s(const int32 port, const int32 io, const int32 data) {
|
|||
static int32 sio0dCore(const int32 port, const int32 io, const int32 data) {
|
||||
int32 ch;
|
||||
const SIO_PORT_INFO spi = lookupPortInfo(port, &ch);
|
||||
assert(spi.port == port);
|
||||
ASSURE(spi.port == port);
|
||||
pollConnection();
|
||||
if (io == 0) { /* IN */
|
||||
if ((sio_unit.flags & UNIT_ATT) && (!sio_unit.u4))
|
||||
|
|
Loading…
Add table
Reference in a new issue