Skip to content

Commit

Permalink
Updated thames to use 8080 emulator allowing basic to be run
Browse files Browse the repository at this point in the history
Added basic executables
  • Loading branch information
ogdenpm committed Jun 8, 2017
1 parent 1daf6fc commit 8ab571c
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 40 deletions.
Binary file added itools/asm86_2.1/asxref
Binary file not shown.
3 changes: 3 additions & 0 deletions itools/basic_1.0/l.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
10 i = 10
20 print i

Binary file added itools/basic_1.1/basic
Binary file not shown.
Binary file added itools/basic_x021/IBASIC
Binary file not shown.
Binary file added itools/utils_2.2/objhex
Binary file not shown.
Binary file added itools/utils_2.2/system.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SHELL= $(ROOT)/unix/bash.exe
DIRS = asm80_4.1 isis.cli_4.1 isis.cli_4.3 isis.ov0_4.3 isis.t0_3.4 isis.t0_4.1\
isis.t0_4.3 isisUtil_4.3 isis_3.4 isis_4.1 isis_4.3 ixref_1.2 ixref_1.3\
kermit lib_2.1 link_3.0 locate_3.0 plm80.lib plm_4.0 system.lib_4.0 tex\
toolbox_1.0
toolbox_1.0 toolbox_2.0


all:
Expand Down
Binary file modified thames.exe
Binary file not shown.
Binary file modified thames32.exe
Binary file not shown.
37 changes: 21 additions & 16 deletions thamesSrc/bin/thames.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,18 @@ void mdsbios(int func, byte *a, byte *b, byte *c, byte *d, byte *e,
/* MDS BIOS traps implemented by ISX but not by THAMES are: */
/* 6: LIST */
/* 7: CONST */
case 7:
if (_isatty(0))
*a = _kbhit() ? 0xff : 0;
else
*a = 0xff;
break;
case 2: /* CONIN */
*a = getchar();
break;
if (_isatty(0) && !(*a = _getch()))
*a = _getch();
else
*a = getchar();
break;
case 4: /* CONOUT */
putchar(*c);
break;
Expand Down Expand Up @@ -144,7 +153,7 @@ void ed_fe(byte *a, byte *b, byte *c, byte *d, byte *e, byte *f,
break;

case 0xC5:
mdsbios((ix[0] & 0xFF) / 3, a, b, c, d, e, h, l);
mdsbios(RAM[0xf990] / 3, a, b, c, d, e, h, l);
break;

default:
Expand Down Expand Up @@ -266,21 +275,17 @@ int main(int ac, char **av)
RAM[0xF801 + 3*n] = 0x80;
RAM[0xF802 + 3*n] = 0xF9;
}
RAM[0xF980] = 0xDD; /* LD (0F990h), IX */
RAM[0xF981] = 0x22;
/* modified to use only 8080 instructions */
RAM[0xF980] = 0xE3; /* XTHL - get callee */
RAM[0xF981] = 0x22; /* SHLD 0F990h - save callee */
RAM[0xF982] = 0x90;
RAM[0xF983] = 0xF9;
RAM[0xF984] = 0xDD; /* POP IX -- IX = address of BIOS entry */
RAM[0xF985] = 0xE1;
RAM[0xF986] = 0x3E; /* LD A, 0C5h */
RAM[0xF987] = 0xC5;
RAM[0xF988] = 0xED; /* EDFE (trap to THAMES) */
RAM[0xF989] = 0xFE;
RAM[0xF98A] = 0xDD; /* LD IX, (0F990h) */
RAM[0xF98B] = 0x2A;
RAM[0xF98C] = 0x90;
RAM[0xF98D] = 0xF9;
RAM[0xF98E] = 0xC9; /* RET */
RAM[0xF984] = 0xE1; /* POP H - restore hl */
RAM[0xF985] = 0x3E; /* LD A, 0C5h */
RAM[0xF986] = 0xC5;
RAM[0xF987] = 0xED; /* EDFE (trap to THAMES) */
RAM[0xF988] = 0xFE;
RAM[0xF989] = 0xC9; /* RET */

RAM[0x40] = 0xC3;
RAM[0x41] = 0xF9;
Expand Down
3 changes: 2 additions & 1 deletion thamesSrc/bin/thames.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
#include <dos.h>
#endif

#define DEBUG 0
/* #define Z80 */ /* uncomment to build z80 emulator (old thames default */
/*#define DEBUG 0*/
/* Library includes */

#ifdef HAVE_LIMITS_H
Expand Down
64 changes: 44 additions & 20 deletions thamesSrc/bin/z80.c
Original file line number Diff line number Diff line change
Expand Up @@ -25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, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S,
4|_S, 0|_S, 0|_S, 4|_S, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S,
0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 0|_S, 4|_S, 4|_S, 0|_S,
4|_S, 0|_S, 0|_S, 4|_S, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S,
0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 0|_S, 4|_S, 4|_S, 0|_S,
0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 0|_S, 4|_S, 4|_S, 0|_S,
4|_S, 0|_S, 0|_S, 4|_S, 0|_S, 4|_S, 4|_S, 0|_S, 0|_S, 4|_S, 4|_S, 0|_S, 4|_S, 0|_S, 0|_S, 4|_S
};

#ifdef DEBUG
Expand All @@ -62,14 +70,20 @@ unsigned short val;

FILE *fptrace = NULL;

void mainloop(word spc, word ssp){
register unsigned char a, f, b, c, d, e, h, l;
unsigned char r, a1, f1, b1, c1, d1, e1, h1, l1, i, iff1, iff2, im;
register unsigned short pc;
unsigned short ix, iy, sp;
// register unsigned long tstates;
register unsigned int radjust;
register unsigned char ixoriy, new_ixoriy;
void mainloop(word spc, word ssp) {
register unsigned char a, f, b, c, d, e, h, l;
unsigned char r, a1, f1, b1, c1, d1, e1, h1, l1, i, iff1, iff2, im;
register unsigned short pc;
unsigned short sp;

unsigned short ix, iy;
#ifdef Z80
// register unsigned long tstates;
register unsigned int radjust;
register unsigned char ixoriy, new_ixoriy;
#else
const unsigned char ixoriy = 0; /* let compiler optimize code*/
#endif
unsigned char intsample;
register unsigned char op;
#ifdef DEBUG
Expand All @@ -82,22 +96,30 @@ void mainloop(word spc, word ssp){

#endif
a=f=b=c=d=e=h=l=a1=f1=b1=c1=d1=e1=h1=l1=i=r=iff1=iff2=im=0;
#ifdef Z80
ixoriy=new_ixoriy=0;
ix=iy=0;
#endif
pc=spc;
sp=ssp;
#ifdef Z80
/*tstates=*/radjust=0;
#endif
while(1){
#ifdef Z80
ixoriy=new_ixoriy;
new_ixoriy=0;
#endif
#ifdef DEBUG
next=(struct _next *)&fetch(pc);
BC=bc;DE=de;HL=hl;AF=(a<<8)|f;
if(fptrace && !ixoriy){
do_log(fptrace,"pc",pc);
if(sp!=sp2)do_log(fptrace,"sp",sp2=sp);
if(iy!=iy2)do_log(fptrace,"iy",iy2=iy);
#ifdef Z80
if(iy!=iy2)do_log(fptrace,"iy",iy2=iy);
if(ix!=ix2)do_log(fptrace,"ix",ix2=ix);
#endif
if(hl!=hl2)do_log(fptrace,"hl",hl2=hl);
if(de!=de2)do_log(fptrace,"de",de2=de);
if(bc!=bc2)do_log(fptrace,"bc",bc2=bc);
Expand All @@ -120,8 +142,10 @@ void mainloop(word spc, word ssp){
intsample=1;
op=fetch(pc);
pc++;
radjust++;
switch(op){
#ifdef Z80
radjust++;
#endif
switch(op){
#include "z80ops.h"
}
}
Expand Down
Loading

0 comments on commit 8ab571c

Please sign in to comment.