mirror of
https://github.com/pevans/erc-c.git
synced 2025-01-17 19:30:13 +00:00
Make position non-static; add case for NULL data
This commit is contained in:
parent
cebdedeff0
commit
4dffea1dda
@ -93,9 +93,18 @@ apple2dd_write_protect(apple2dd *drive, bool protect)
|
|||||||
drive->write_protect = protect;
|
drive->write_protect = protect;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
position(apple2dd *drive)
|
apple2dd_position(apple2dd *drive)
|
||||||
{
|
{
|
||||||
|
// Special case: they didn't load any image data into the "drive".
|
||||||
|
// Return zero.
|
||||||
|
if (drive->data == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is a normative DOS 3.3 / ProDOS disk. (Except ProDOS is
|
||||||
|
// separated into 512 byte blocks which _shouldn't_ matter for our
|
||||||
|
// purposes but let's not talk about that here do-de-doo.)
|
||||||
if (drive->data->size == _140K_) {
|
if (drive->data->size == _140K_) {
|
||||||
int track_offset;
|
int track_offset;
|
||||||
|
|
||||||
@ -109,7 +118,7 @@ position(apple2dd *drive)
|
|||||||
vm_8bit
|
vm_8bit
|
||||||
apple2dd_read_byte(apple2dd *drive)
|
apple2dd_read_byte(apple2dd *drive)
|
||||||
{
|
{
|
||||||
vm_8bit byte = vm_segment_get(drive->data, position(drive));
|
vm_8bit byte = vm_segment_get(drive->data, apple2dd_position(drive));
|
||||||
|
|
||||||
// We may have read the very last byte in a sector; if so let's
|
// We may have read the very last byte in a sector; if so let's
|
||||||
// adjust the track_pos by two half tracks and reset the sector pos.
|
// adjust the track_pos by two half tracks and reset the sector pos.
|
||||||
@ -125,7 +134,7 @@ apple2dd_read_byte(apple2dd *drive)
|
|||||||
void
|
void
|
||||||
apple2dd_write(apple2dd *drive, vm_8bit byte)
|
apple2dd_write(apple2dd *drive, vm_8bit byte)
|
||||||
{
|
{
|
||||||
vm_segment_set(drive->data, position(drive), byte);
|
vm_segment_set(drive->data, apple2dd_position(drive), byte);
|
||||||
|
|
||||||
drive->sector_pos++;
|
drive->sector_pos++;
|
||||||
if (drive->sector_pos > MAX_SECTOR_POS) {
|
if (drive->sector_pos > MAX_SECTOR_POS) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user