Furthered fleshing out of the 1540. Though it doesn't yet receive a ROM so won't even attempt to do anything meaningful.

This commit is contained in:
Thomas Harte 2016-07-05 16:39:18 -04:00
parent a25fcc7190
commit 86dabd007b
7 changed files with 85 additions and 10 deletions

View File

@ -7,3 +7,29 @@
//
#include "Commodore1540.hpp"
#include <string.h>
using namespace Commodore::C1540;
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
if(address < 0x800)
{
if(isReadOperation(operation))
*value = _ram[address];
else
_ram[address] = *value;
}
else if(address >= 0xc000)
{
if(isReadOperation(operation))
*value = _rom[address & 0x3fff];
}
return 1;
}
void Machine::set_rom(uint8_t *rom)
{
memcpy(_rom, rom, sizeof(_rom));
}

View File

@ -9,6 +9,26 @@
#ifndef Commodore1540_hpp
#define Commodore1540_hpp
#include <stdio.h>
#include "../../../Processors/6502/CPU6502.hpp"
#include "../../../Components/6522/6522.hpp"
namespace Commodore {
namespace C1540 {
class Machine:
public CPU6502::Processor<Machine> {
public:
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
void set_rom(uint8_t *rom);
private:
uint8_t _ram[0x800];
uint8_t _rom[0x4000];
};
}
}
#endif /* Commodore1540_hpp */

View File

@ -54,6 +54,9 @@ Machine::Machine() :
write_to_map(_processorWriteMemoryMap, _userBASICMemory, 0x0000, sizeof(_userBASICMemory));
write_to_map(_processorWriteMemoryMap, _screenMemory, 0x1000, sizeof(_screenMemory));
write_to_map(_processorWriteMemoryMap, _colorMemory, 0x9400, sizeof(_colorMemory));
// TEMPORARY: attach a [diskless] 1540
set_disc();
}
void Machine::write_to_map(uint8_t **map, uint8_t *area, uint16_t address, uint16_t length)
@ -121,6 +124,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
_keyboardVIA->run_for_half_cycles(2);
if(_typer) _typer->update(1);
_tape.run_for_cycles(1);
if(_c1540) _c1540->run_for_cycles(1);
return 1;
}
@ -150,9 +154,11 @@ void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data)
size_t max_length = 0x2000;
switch(slot)
{
case ROMSlotKernel: target = _kernelROM; break;
case ROMSlotCharacters: target = _characterROM; max_length = 0x1000; break;
case ROMSlotBASIC: target = _basicROM; break;
case Kernel: target = _kernelROM; break;
case Characters: target = _characterROM; max_length = 0x1000; break;
case BASIC: target = _basicROM; break;
case Drive:
return;
}
if(target)
@ -323,3 +329,10 @@ void Tape::process_input_pulse(Storage::Tape::Pulse pulse)
if(_delegate) _delegate->tape_did_change_input(this);
}
}
#pragma mark - Disc
void Machine::set_disc()
{
_c1540.reset(new ::Commodore::C1540::Machine);
}

View File

@ -13,6 +13,7 @@
#include "../../../Storage/Tape/Tape.hpp"
#include "../../../Components/6560/6560.hpp"
#include "../../../Components/6522/6522.hpp"
#include "../1540/Commodore1540.hpp"
#include "../SerialBus.hpp"
#include "../../CRTMachine.hpp"
@ -22,9 +23,10 @@ namespace Commodore {
namespace Vic20 {
enum ROMSlot {
ROMSlotKernel,
ROMSlotBASIC,
ROMSlotCharacters,
Kernel,
BASIC,
Characters,
Drive
};
#define key(line, mask) (((mask) << 3) | (line))
@ -235,6 +237,7 @@ class Machine:
void set_rom(ROMSlot slot, size_t length, const uint8_t *data);
void add_prg(size_t length, const uint8_t *data);
void set_tape(std::shared_ptr<Storage::Tape> tape);
void set_disc();
void set_key_state(Key key, bool isPressed) { _keyboardVIA->set_key_state(key, isPressed); }
void clear_all_keys() { _keyboardVIA->clear_all_keys(); }
@ -296,6 +299,9 @@ class Machine:
// Tape
Tape _tape;
bool _use_fast_tape_hack;
// Disc
std::shared_ptr<::Commodore::C1540::Machine> _c1540;
};
}

View File

@ -15,6 +15,7 @@
- (void)setKernelROM:(nonnull NSData *)rom;
- (void)setBASICROM:(nonnull NSData *)rom;
- (void)setCharactersROM:(nonnull NSData *)rom;
- (void)setDriveROM:(nonnull NSData *)rom;
- (void)setPRG:(nonnull NSData *)prg;
- (BOOL)openTAPAtURL:(nonnull NSURL *)URL;

View File

@ -29,15 +29,19 @@ using namespace Commodore::Vic20;
}
- (void)setKernelROM:(nonnull NSData *)rom {
[self setROM:rom slot:ROMSlotKernel];
[self setROM:rom slot:Kernel];
}
- (void)setBASICROM:(nonnull NSData *)rom {
[self setROM:rom slot:ROMSlotBASIC];
[self setROM:rom slot:BASIC];
}
- (void)setCharactersROM:(nonnull NSData *)rom {
[self setROM:rom slot:ROMSlotCharacters];
[self setROM:rom slot:Characters];
}
- (void)setDriveROM:(nonnull NSData *)rom {
[self setROM:rom slot:Drive];
}
- (BOOL)openTAPAtURL:(NSURL *)URL {

View File

@ -0,0 +1,5 @@
ROM files would ordinarily go here; the copyright status of these is uncertain so they have not been included in this repository.
Expected files:
1540.rom; a 16kb image of the 1540's ROM area.