SPeccy ON the ZeddY

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
Post Reply
User avatar
siggi
Posts: 883
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: SPeccy ON the ZeddY

Post by siggi » Sat Jan 07, 2012 2:54 pm

I tested the new SPONZY version and that is the result:
the display is still flickering on my LCD display of my laptop Zeddy (as I wrote above: my LCD is very sensitive!).
And now, the middle line of the character "E" is missing.
Here the LCD:
P1050109_640x480.JPG
P1050109_640x480.JPG (145.67 KiB) Viewed 3098 times
And here on a CRT:
P1050107_640x480.JPG
P1050107_640x480.JPG (90.33 KiB) Viewed 3098 times
And a minor problem when pressing a key: sometimes (every 10th keypress or so) the screen gets out of sync and "jumps" a little bit to the left and back to the right..

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
1024MAK
Posts: 2539
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: SPeccy ON the ZeddY

Post by 1024MAK » Sun Jan 08, 2012 9:15 pm

Andy Rea wrote:Seriously impressive... How dare you Sir !
An understatement if i ever saw one, Great work Zsolt, who da thought running Speccy on '81 hardware...
F**** Awesome, i'm loving the BBC / Acorn basic port.
Andy
Hi Zsolt
I'm lost for words (and looking for suitable words in a English dictionary did not help :o ). So I'll have to stick to:
Excellent work 8-)
You must have used the power of the force to manage this amazing feat :D
Now please, don't tell me that you are now working out how to download the Death Star OS into a Zeddy :shock: :lol:
I wonder what the various "my machine is better than yours" users would have made of ZX81's running Speccy programs, Speccy's running ZX81 programs, both ZX81's and Speccy's running BBC BASIC :?: :lol:
Mark
PS by the way, some BBC Micro users are porting some ZX Spectrum titles to the Beeb. Whatever next?

User avatar
siggi
Posts: 883
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: SPeccy ON the ZeddY

Post by siggi » Mon Jan 09, 2012 4:40 pm

dr beep wrote: After loading you must jump to the next statement routine in ROM.

When however you have an interface connected with alternative rom then it is much easier to alter the load/save routine only
and so asking the info you need. With my ZX-PC interface I only altered the reading from tape to reading from diskette/harddisk.

at #556 the loader of the ROM starts (see http://www.wearmouth.demon.co.uk/zx82.htm#L0556)
when you alter the code after the PUSH HL you can use your own reading/writing method.

You can then use the normal LOAD "NAME" and SAVE "NAME" routine.
Perhaps we can work this out together?
Hi Dr Beep
here is my code to load a program from a TAP file (the assembler code is "borrowed" from Winston's basic load routine of SPECTRANET and adapted to my needs). Is that sufficient or have I forgotten something to do?

"RunProgram" is the function to load the program.

Code: Select all

unsigned int ZX_PROG @ 23635;
unsigned int ZX_VARS @ 23627;
unsigned int ZX_E_LINE @ 23641;
unsigned int ZX_NEWPPC @ 23618;
unsigned int ZX_E_PPC @ 23625;

void __FASTCALL__ PrepBasicLoad(char * addr)
{
#asm
;----------------------------------------------------------------------------
; Parameters: HL points to the "tape" header (i.e. TAP block + 2)
; Much of this is modelled on the ZX ROM loader.
DEFC CALLBAS 		=	0x0010
DEFC ZX_RECLAIM_1	=	0x19E5
DEFC ZX_MAKE_ROOM	=	0x1655

    push HL ; save tape header address
    pop IX  ; get it into IX
	ld hl, (_ZX_E_LINE)	; End marker of current variables area
	ld de, (_ZX_PROG)	; Destination address
	dec hl
	push IX				; save IX
	ld c, (ix+0x0b)		; Length argument in "tape" header
	ld b, (ix+0x0c)
	push bc			; save the length
	rst CALLBAS
	defw ZX_RECLAIM_1	; Reclaim present program/vars
	pop bc
	rst CALLBAS
	defw ZX_MAKE_ROOM	; Call MAKE_ROOM to make speace for program
	pop IX				; restore IX
	inc hl				; The system variable VARS
	ld c, (ix+0x0f)		; needs to be set.
	ld b, (ix+0x10)
	add hl, bc
	ld (_ZX_VARS), hl
	ld c, (ix+0x0d)     ; get autorun line
	ld b, (ix+0x0e)
	ld (_ZX_NEWPPC), bc  ; set system vars
	ld (_ZX_E_PPC), bc
#endasm
}

/*  int RunProgram(char *fname, int executeflag)
 *
 *  Loads the program named fname into memory, and if executeflag is set runs it.
 *
 */
int RunProgram(char *fname, int execute)
{
        DIRENT dir;
        char *src, *dest;
        long Cluster;
        int len, count, *ClusP=&Cluster;

        FATSaveFAT(); // Save any changes before we potentially
                      // Crash the machine :)

        if (!FindPath(fname, &dir, &Cluster))
        {
            if (!(dir->attr & 16)) // Check to ensure it's really a file,
                                // not a directory.
            {
                *(ClusP++)=dir.clusterl;
                *(ClusP)=dir.clusterh & 0x0fff;
                len=dir.size;

                FATLoadBlock(Cluster);     /* load first 512 byte (containing the TAP header) */

                src=SectorBuffer;
                if (*src++ == 0x13) // check length of header
                if (*src++ == 0)    // must be 0
                if (*src++ == 0)    // must be 0 for "header"
                if (*src == 0)      // must be 0 for "BASIC"
                {
                    PrepBasicLoad(SectorBuffer + 2); /* address is header byte */

                    // 3 byte TAP + 17 bytes ZX + 1 check byte + 2 byte block length + 1 byte flag = 24 byte
                    len = len - 24; /* data length. Correct? */
                    count = 512 - 24;
                    dest = (char *) ZX_PROG;
                    src = SectorBuffer + 23; /* points to data. Correct? */

                    while(len)
                    {
                            *(dest++)=*(src++);
                            len--; count--;

                            if (!count)
                            {
                                    FATLoadNextBlock();
                                    src=SectorBuffer;
                                    count=512;
                            }
                    }

                    if(execute == '+')
                    {
                            ZXSlow();
#asm
                            rst     8      ; works on Zeddy: But also on SPONZY?
                            defb    $FF
#endasm
                    }
                    else if (execute == '-')
                    {
	                    ZX_NEWPPC = 32768;     /* destroy autorun info */
                    }
                    ZX81Cls();
                    return(EOK);
                }

            }
        }
        return(ENOFILE);
}

Is
RST 8
DEFB $FF

also working with a Speccy? With a Zeddy that is used to cleanup the stack and jump back to BASIC without any error and continue a running BASIC program. Or do I have to use a
JMP ????
to go back and to run the loaded program?

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
zsolt
Posts: 197
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: SPeccy ON the ZeddY

Post by zsolt » Sat Jan 14, 2012 1:23 pm

Dear All,

When I read this topic, I wondered a little, because i store my actual projects in several places: on a PC,
on my Laptop and on a pendrive. But it is not enough. If we does not keep them in sync, then bizarre things can happen:


After the image problems reported by Siggi, SPONZY was tried with all of our TV devices - see the picture.
SponzyDisplay.jpg
(361.6 KiB) Downloaded 1361 times
The error did not come forward.

Then I rebuilt the software to make more room for the upcoming fastloader (from FLASHROM).

And I tried ... and I was shocked - the picture flickered on my TV, too.

I checked the display routine and already had a guess what could have happened.
Having compared the previously uploaded SPONZY.ROM with the contents of the FLASHROM, I already knew:
My laptop was updated with the newer (not tested) version (oh, synchronization), so it was a temporary version uploaded for you - sorry. You can find the above mentioned (already improved) version (and a TAP / WAV converter) in the attachment.

Siggi, about the loading part I have a new idea.

The programs for Speccy are generally built up so: a program, datablock 1, datablock 2,..., datablock n.
That program controlls the loading of each blocks and starts the main program(loop).

I modified the ROM to call the header/block loader part via a pointer. This solution is the base for the next step of the development: loading the programs stored in the FLASH. We have to implement the block loader interface only, the ROM takes care of the rest.

What I mean? See in the attachment (sponzy_s9alpha).

Regards
Zsolt

EDIT: the attachment was removed. Here is the final version of SPONZY
Last edited by zsolt on Mon May 28, 2012 9:06 pm, edited 1 time in total.
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

User avatar
siggi
Posts: 883
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: SPeccy ON the ZeddY

Post by siggi » Sun Jan 15, 2012 11:41 am

zsolt wrote: Siggi, about the loading part I have a new idea.

The programs for Speccy are generally built up so: a program, datablock 1, datablock 2,..., datablock n.
That program controlls the loading of each blocks and starts the main program(loop).

I modified the ROM to call the header/block loader part via a pointer. This solution is the base for the next step of the development: loading the programs stored in the FLASH. We have to implement the block loader interface only, the ROM takes care of the rest.
Hi Zsolt
is the block loader routine responsible to understand the information in the TAP headers?
If yes, I would prefer a solution, where this is done by the Sponzy Rom, because I am not familiar with Speccy tape headers and how they have to be handled. I could write a routine, which reads byte per byte from MMC (without interpretation of their meaning), until an end-of-file is met, and pass that bytes to another routine (in ROM), which knows, what they mean and what to do with them.
Would that be enough to read a TAP file with many blocks? Or would it be necessary to "seek" back/forward to any position in the TAP file?

And what about SAVE?
SAVE "" could also jump to my FAT32-program (*) (above 32K) and I could prepare a TAP file for writing.
I don't know about headers and checksums to be made (this should be done in ROM), but could write byte per byte write to MMC (until a end-of-file condition is reported by the ROM routine).
Again: Would that be enough to write a TAP file with many blocks? Or would it be necessary to "seek" back/forward to any position in the TAP file?

Siggi

(*) I currently do not know, how the C program could know, whether it was called by LOAD"" or SAVE"". Is it possible on a Speccy to pass parameters to a C program, when calling it?
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
zsolt
Posts: 197
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: SPeccy ON the ZeddY

Post by zsolt » Sun Jan 15, 2012 10:01 pm

Hi Siggi,
LoaderFlowChart.jpg
(108.86 KiB) Downloaded 1285 times
A code for loading a block:

Code: Select all

BlkLoader
	call ReadMMCByte	; dummy read: LSB of length of block
	call ReadMMCByte	; dummy read: MSB of length of block
	;
	call ReadMMCByte	; dummy read: flag byte
NextByte
	call ReadMMCByte	; a data byte from a block
	;
	ld (ix),a			; if you give it back in A-register
	inc ix			; set pointer to the next location
	dec de			; decrement counter
	ld a,d			; it was the last
	or e				; data byte?
	jr nz,NextByte		; back if not
	;
	call ReadMMCByte	; dummy read: checksum
	;
	scf				; if CY is set, then no error occured 
	;
	ret				;

Where the 'ReadMMCByte' is your function to read a byte from an already opened file.
(And it closes the file if EOF=true)

Save "" ? - is also solvable.
Testing the lo byte of the system variable T_ADDR($5C74) you will know, whether Save or Load was called,
depending on its value: it is 0 for Save and 1 for Load.

Code: Select all

FileMan
	ld hl,$5C74		;
	ld a,(hl)			; fetch T_ADDR
	;
	; If your file manager begins with these two commands,
	; I can check whether to give the control to it.
	;
 	cp $01			;
	jp c,SavePart		;
	;

	; here you can select and open a TAP file

	;
	ld hl,FileMan-1		; set up 
	ld de,BlkLoader		; the 
	ld (hl),d			; pointer
	dec hl			;
	ld (hl),e			;
	ret				; 
;
;  The next one is more complicated. I don't know the good solution - yet.
; 
SavePart
	RST	08H			; ERROR-1
	DEFB	$0E			; Error Report: Invalid file name
Don't forget the startup!

Code: Select all

	out ($FD),a		; Switch NMI off!
	ld b,$00			; signal of cold start
	ld hl,FileMan		; addr. of the first invalid
					; location (for SPONZY)
	jp $11E5			; RAM-DONE
Grüss
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

PrimitivePerson
Posts: 17
Joined: Fri Oct 22, 2010 6:55 pm

Re: SPeccy ON the ZeddY

Post by PrimitivePerson » Sun Jan 15, 2012 11:07 pm

Has anyone tried running all of this on a real ZX81 using ZXPand?

Can we have some idiot-proof instructions?!?

Lee

User avatar
siggi
Posts: 883
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: SPeccy ON the ZeddY

Post by siggi » Mon Jan 16, 2012 9:04 am

Hi ZSOLT
I think, that the block loader routine will be the same for all file system load methods. So it could be in ROM. Right?
Only the "ReadMMCByte" routine is individual for each file system. So wouldn't it be sufficient to pass the pointer to "ReadMMCByte" to the SPONZY load routine?
And the same for SAVE: pass only the pointer to "WriteMMCByte".

And we would also need a method to tell the mmc-filemanager to close an open file ...

Siggi

PS: are concurrent actions posible (e.g. read a file and write another, while the first file is still open for reading)?
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
siggi
Posts: 883
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: SPeccy ON the ZeddY

Post by siggi » Mon Jan 16, 2012 9:06 am

PrimitivePerson wrote:Has anyone tried running all of this on a real ZX81 using ZXPand?

Can we have some idiot-proof instructions?!?

Lee
You need 16kByte ram or (E)EPROM at address 0-16383 to hold the SPONZY rom. AFAIK that is not possible with ZXPAND. And ZXPAND normally does ROM-patches, which fit to a ZX81 rom, but not to a SPONZY rom ...

Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

sirmorris
Posts: 2813
Joined: Thu May 08, 2008 5:45 pm

Re: SPeccy ON the ZeddY

Post by sirmorris » Mon Jan 16, 2012 1:07 pm

I smell a challenge :)

It would require a custom GAL and possibly a couple of mods to the ZXpand board.

<watch this space>

Post Reply