Apple ][ CP/M

Discussion about other targets
Post Reply
stefano
Well known member
Posts: 2328
Joined: Mon Jul 16, 2007 7:39 pm

Apple ][ CP/M

Post by stefano »

The recent versions of the AppleWin emulator include support for the Z80 SoftCard and the emulator itself is reasonably simple to work on (still, it's not if you never set up a CP/M HW configuration on an Apple 2). I suggest to try with something very basic, say Apple ][ or Apple ][ + with the Z80 card installed on slot 4.
The disk image we already have in appmake will work fine ("+cpm -subtype=apple2" creates a 16 trk disk image file) but we miss a system specific library.

I looked at the MS GBASIC implementation to learn a little more about HW specific capabilities and I stumbled in this piece of code:

@label=INIT
*04096 LD HL,25744
04099 LD DE,33922
04102 LD BC,21635
04105 LDDR
04107 JP 33235

So, the higher portion of the BASIC interpreter gets shiftetd 8178 bytes high (the block between 4109 (shouldn't it be 4110 ? perhaps it is a sort of protection?) and 25744 is moved to the 12287..33922 range. The entry addresses in the binary file look shifted of 8178 bytes compared to the expected position, exactly 8192 minus the 14 bytes relocator above... I must have misinterpreted the LDDR range.


EDIT: my hack to force a relocation and prepare GBASIC for BASCK

Code: Select all

/*
 *    Expanding the Apple ][ GBASIC.COM file for an easier analysis
 *    BASCK needs to be modified (remove the GBASIC hack and force ORG to $100)
 *
 *	$Id: split.c$
 */

#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[])
{
	FILE	*fpin, *fpout;
	int	c;
	int	i,x;
	int	len;
	int	pos;

	
	pos=4096-256+14;

	if ( (fpin=fopen(argv[1],"rb") ) == NULL ) {
		printf("Can't open input file\n");
		exit(1);
	}

/*
 *	Now we try to determine the size of the file
 *	to be converted
 */
	if	(fseek(fpin,0,SEEK_END)) {
		printf("Couldn't determine size of file\n");
		fclose(fpin);
		exit(1);
	}

	len=ftell(fpin);

	fseek(fpin,0L,SEEK_SET);

	if ( (fpout=fopen(argv[2],"wb") ) == NULL ) {
		printf("Can't open output file\n");
		exit(1);
	}

	for (i=0; i<len;i++) {
		if (i==pos) {
			for (x=0; x<8178;x++)
				fputc(0,fpout);
		}
		c=getc(fpin);
		fputc(c,fpout);
	}
	fclose(fpin);
	fclose(fpout);
}
		

The only reason I can imagine to do so is to avoid using the memory space between 4096 and 12287, probably that 8k window is the graphics memory.
stefano
Well known member
Posts: 2328
Joined: Mon Jul 16, 2007 7:39 pm

Re: Apple ][ CP/M

Post by stefano »

A very first draft of the GBASIC.COM disassembly for the Apple ][

I'll be AFK for some day, so here it is:

https://github.com/z88dk/techdocs/blob/ ... gbasic.asm


.. and this is probably an interesting reading too, the ALS board is probably not identical to the softcard, but it gives hints on how the architecture worked

https://mirrors.apple2.org.za/ftp.apple ... rs/z80.pdf
Post Reply