Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jscrane committed Aug 24, 2024
1 parent c6255d5 commit ec6e3ae
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
4 changes: 3 additions & 1 deletion cpm80.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ram<> pages[RAM_PAGES];
void reset(void) {
bool disk = hardware_reset();

kbd.reset();
io.reset();

unsigned i;
for (i = 0; i < sizeof(cpm22); i++)
Expand All @@ -57,6 +57,8 @@ void reset(void) {
void function_key(uint8_t fn) {
if (fn == 1)
reset();
else if (fn == 10)
hardware_debug_cpu();
}

void setup(void) {
Expand Down
22 changes: 11 additions & 11 deletions io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include "io.h"

void IO::reset() {
dsk_reset();
_kbd.reset();
scr_reset();
dsk_reset();
_brk = true;
}

Expand All @@ -33,13 +33,13 @@ uint8_t IO::kbd_poll() {
uint8_t IO::in(uint16_t port, i8080 *cpu) {

switch(port & 0xff) {
case 4:
return kbd_poll();
case 2:
case CON_ST:
return _kbd.available()? 0xff: 0x00;
case 14:
case CON_IN:
return kbd_poll();
case FDC_IN:
return dsk_read();
case 15:
case FDC_OUT:
return dsk_write();
default:
DBG(printf("IO: unhandled input port: %x\r\n", port));
Expand All @@ -50,19 +50,19 @@ uint8_t IO::in(uint16_t port, i8080 *cpu) {
void IO::out(uint16_t port, uint8_t a, i8080 *cpu) {

switch(port & 0xff) {
case 4:
case CON_OUT:
scr_display(a);
break;
case 20:
case FDC_SELDSK:
dsk_select(a);
break;
case 21:
case FDC_SETTRK:
settrk = a;
break;
case 22:
case FDC_SETSEC:
setsec = a;
break;
case 23:
case FDC_SETDMA:
setdma = cpu->hl();
break;
default:
Expand Down
13 changes: 13 additions & 0 deletions io.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@

class serial_kbd;

// input ports (see CBIOS.ASM)
#define CON_ST 2
#define CON_IN 4
#define FDC_IN 14
#define FDC_OUT 15

// output ports
#define CON_OUT 4
#define FDC_SELDSK 20
#define FDC_SETTRK 21
#define FDC_SETSEC 22
#define FDC_SETDMA 23

class IO: public PortDevice<i8080>, public Display {
public:
IO(Memory &mem, serial_kbd &kbd): _mem(mem), _kbd(kbd) {}
Expand Down

0 comments on commit ec6e3ae

Please sign in to comment.