Skip to content

Commit

Permalink
- support transmit interrupts on serial devices
Browse files Browse the repository at this point in the history
- support interrupts in emulated drives
- emulate the 88-RTC-VI vector real time clock and interrupt board
- base timing interrupts on simulated time instead of real time
- added more options to configuration menu
- added disks for Time Sharing Basic
- removed cpucore_v1 implementation
  • Loading branch information
dhansel committed Feb 11, 2017
1 parent c298a4a commit 0e8ee64
Show file tree
Hide file tree
Showing 10 changed files with 468 additions and 64 deletions.
File renamed without changes.
62 changes: 44 additions & 18 deletions cpucore.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
#ifndef CPUCORE_H
#define CPUCORE_H

#include "config.h"

#define PS_CARRY 0x01
#define PS_PARITY 0x04
#define PS_HALFCARRY 0x10
#define PS_ZERO 0x40
#define PS_SIGN 0x80

#if CPUCORE_VERSION == 1
#include "cpucore_v1.h"
#elif CPUCORE_VERSION == 2
#include "cpucore_v2.h"
#else
#error "invalid CPU core emulator version"
#endif
#ifndef CPUCORE_V2_H
#define CPUCORE_V2_H

#include <Arduino.h>

extern union unionBC
{
struct { byte C, B; };
uint16_t BC;
} regBC;

extern union unionDE
{
struct { byte E, D; };
uint16_t DE;
} regDE;

extern union unionHL
{
struct { byte L, H; };
uint16_t HL;
} regHL;

extern union unionPC
{
struct { byte L, H; };
uint16_t PC;
} regPCU;

extern byte regS;
extern byte regA;
extern uint16_t regSP;

#define regB regBC.B
#define regC regBC.C
#define regD regDE.D
#define regE regDE.E
#define regH regHL.H
#define regL regHL.L
#define regPC regPCU.PC

typedef void (*CPUFUN)();
extern CPUFUN cpu_opcodes[256];
#define CPU_EXEC(opcode) (cpu_opcodes[opcode])()

#endif
46 changes: 0 additions & 46 deletions cpucore_v2.h

This file was deleted.

Binary file added disks/DISK09.DSK
Binary file not shown.
Binary file added disks/DISK0A.DSK
Binary file not shown.
Binary file added disks/DISK0B.DSK
Binary file not shown.
107 changes: 107 additions & 0 deletions prog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include <Arduino.h>
#include "prog.h"
#include "Altair8800.h"
#include "prog_basic.h"
#include "prog_tools.h"
#include "prog_games.h"
#include "prog_ps2.h"
#include "numsys.h"


struct prog_info_struct {
PGM_P name;
uint16_t (*load)(byte *);
bool run;
};


uint16_t prog_print_dir(byte *mem);


struct prog_info_struct get_prog_info(byte i)
{
struct prog_info_struct programs[] =
{
{PSTR("[print this directory]"), prog_print_dir, false},
{PSTR("Calculator"), prog_tools_copy_calc, true},
{PSTR("Kill-the-Bit"), prog_games_copy_killbits, true},
{PSTR("Pong (LEDs)"), prog_games_copy_pong, true},
{PSTR("Pong (Terminal)"), prog_games_copy_pongterm, true},
{PSTR("4k Basic"), prog_basic_copy_4k, true},
#if !defined(__AVR_ATmega2560__)
{PSTR("MITS Programming System II"), prog_ps2_copy_monitor, true},
{PSTR("ALTAIR Turnkey Monitor"), prog_tools_copy_turnmon, true},
{PSTR("Disk boot ROM"), prog_tools_copy_diskboot, true},
{PSTR("Music ('Daisy')"), prog_games_copy_daisy, true},
#endif
{PSTR("CPU Diagnostic"), prog_tools_copy_diag, true},
{PSTR("CPU Exerciser"), prog_tools_copy_exerciser, true},
{PSTR("Status lights test"), prog_tools_copy_statustest, false},
{PSTR("Serial echo using IRQ"), prog_tools_copy_serialirqtest, false},
{PSTR("16k ROM Basic"), prog_basic_copy_16k, true},
{NULL, NULL, false}
};

return programs[i];
}


uint16_t prog_print_dir(byte *mem)
{
int i = 0;

Serial.println();
while( get_prog_info(i).name!=NULL )
{
numsys_print_byte_bin(i);
Serial.print(F(") "));
Serial.println(FP(get_prog_info(i).name));
i++;
}

Serial.println(F("10nnnnnn) [load memory page, nnnnnn=file number]"));
Serial.println(F("11nnnnnn) [save memory page, nnnnnn=file number]"));
}


byte prog_find(const char *name)
{
for(byte i=0; i<0xff; i++)
{
if( get_prog_info(i).name == NULL )
return 0;
else if( strcmp_P(name, get_prog_info(i).name)==0 )
return i;
}

return 0;
}


const char *prog_get_name(byte n)
{
// check that program #n exists
for(int i=0; i<n; i++)
if( get_prog_info(i).name == NULL )
return NULL;

return get_prog_info(n).name;
}


bool prog_load(byte n, uint16_t *pc, byte *mem)
{
// check that program #n exists
for(int i=0; i<=n; i++)
if( get_prog_info(i).name == NULL )
return false;

uint16_t addr = get_prog_info(n).load(mem);
if( addr<0xffff )
{
*pc = addr;
return get_prog_info(n).run;
}
else
return false;
}
17 changes: 17 additions & 0 deletions prog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef PROG_H
#define PROG_H

#include <Arduino.h>

#if defined(__AVR_ATmega2560__)
#define FP(x) (__FlashStringHelper *)(x)
#else
#define FP(x) x
#endif


byte prog_find(const char *name);
PGM_P prog_get_name(byte n);
bool prog_load(byte n, uint16_t *pc, byte *mem);

#endif
Loading

0 comments on commit 0e8ee64

Please sign in to comment.