SPeccy ON the ZeddY

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
dr beep
Posts: 1212
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: SPeccy ON the ZeddY

Post by dr beep » Mon Jan 02, 2012 1:11 pm

siggi wrote:I would like (as a first step) load a complete program (like a .P file for ZX81).
- Which Speccy file type is equivalent to a ZX81 P-file? And where (at which address) do I have to load it?
- Do I have to update afterwards some system variables?
- Which address range has to be written to MMC to save a complete program?
The best fitting equivalant is the TAP-file. A TAP-file holds either BASIC, CODE or DATA segments (depending on the header each block of code has).
Also the location where it is loaded is depending on the type of header. BASIC loads from start of basic (which can be altered with a ZX IF 1).
CODE loads according to the header in the data and DATA on the place used for variables.

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 02, 2012 1:58 pm

Hi dr beep
is that the header you wrote about (I found it here: http://www.tjornov.dk/spectrum/faq/fileform.html#TAPZ )

Code: Select all

For completeness, I'll include the structure of a tape header. A header always consists of 17 bytes:

        Byte    Length  Description
        ---------------------------
        0       1       Type (0,1,2 or 3)
        1       10      Filename (padded with blanks)
        11      2       Length of data block
        13      2       Parameter 1
        15      2       Parameter 2

The type is 0,1,2 or 3 for a Program, Number array, Character array or Code file. A SCREEN$ file is regarded as a Code file with start address 16384 and length 6912 decimal. If the file is a Program file, parameter 1 holds the autostart line number (or a number >=32768 if no LINE parameter was given) and parameter 2 holds the start of the variable area relative to the start of the program. If it's a Code file, parameter 1 holds the start of the code block when saved, and parameter 2 holds 32768. For data files finally, the byte at position 14 decimal holds the variable name.
And could you tell my the numeric address, where a basic program should be loaded (I don't know the Speccy memory map and of course don't have a ZX IF 1 connected to my Zeddy ;-) )

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

dr beep
Posts: 1212
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: SPeccy ON the ZeddY

Post by dr beep » Mon Jan 02, 2012 2:20 pm

Yes, that's the header.

By heart; game loads at #5ccc
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?

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 02, 2012 3:23 pm

I don't want to "patch" the new Sponzy rom now. I just would like to use the FAT32-program like on my Zeddy: it has its own command line interface to load/save file and runs above 32K. That is easier to test than changes in rom.

My idea is, to boot as Zeddy, load the (SPONZY-)FAT32-program from MMC into higth ram (>32K) and switch to SPONZY rom (reboots as 16K-Speccy).
But I found, that the memory above 32K seems to be cleared during SPONZY boot (despite it emulates a 16K Speccy). So the FAT32 program is overwritten ...

Maybe ZSOLT can tell some details about SPONZY boot?

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

dr beep
Posts: 1212
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: SPeccy ON the ZeddY

Post by dr beep » Mon Jan 02, 2012 3:30 pm

Only way is to 'protect' the upper 16K.

Boot starts in normal ZX Spectrum ROM at #FFFF and then filling all RAM with 02.
Or you must start ROM like this:

DI
XOR A
LD DE,#7FFF ; 16K only, upper RAM not used
JP #11CB

You must set #8000 with a value unequal 2 and it must be allowed to be overwritten!
start the mentioned code and not the normal ROM at #0000

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 02, 2012 6:01 pm

dr beep wrote: Or you must start ROM like this:

DI
XOR A
LD DE,#7FFF ; 16K only, upper RAM not used
JP #11CB
I used that code, but did not patch the rom, but added that code to the bankswitching routine, which is used to jump from ZX81 into SPONZY rom.

Thanks
Siggi
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: IX/IY usage

Post by siggi » Tue Jan 03, 2012 2:35 pm

Hi ZSOLT
AFAIK on a Speccy the usage of the IX register by user programs is allowed. But what about reserved registers of a SPONZY? Are (like in a ZEDDY) the registers AF' and IX "forbidden" (maybe used by the NMI/display routine)? And probably also IY?

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

dr beep
Posts: 1212
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: SPeccy ON the ZeddY: IX/IY usage

Post by dr beep » Tue Jan 03, 2012 3:05 pm

siggi wrote:Hi ZSOLT
AFAIK on a Speccy the usage of the IX register by user programs is allowed. But what about reserved registers of a SPONZY? Are (like in a ZEDDY) the registers AF' and IX "forbidden" (maybe used by the NMI/display routine)? And probably also IY?

Siggi
If you don't use ROM-routines at all then all registers are allowed on the Spectrum.
For systemvars you need IY, but without ROM IY can be used. For returning to BASIC you also need HL', but
without BASIC you may use everything.

Values:
IY = #5c3a
HL'= #2758

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 » Tue Jan 03, 2012 11:15 pm

Hi Siggi,

Sorry for the delay.
zsolt wrote:
  • in PAL mode: 1 frame ~= 312 scanline (312*207TS -> 19.872 msec ~50,322Hz)
    in NTSC mode: 1 frame ~= 262 scanline (262*207TS -> 16.687 msec ~59,925Hz)
It seems that there is a reserve in PAL mode (<20 msec), therefore the length of the frame can be extended.
In the revised version 314 scanline forms a frame: 314*207TS -> 19.999 ms ~ 50.002 Hz.
this may cause the flickering display - I rebuilt the program w.312 scanline - try it, pls.

- Which Speccy file type is equivalent to a ZX81 P-file? -> as drBeep wrote the TAP

- And where (at which address) do I have to load it? -> SysVAR PROG (23635=$5C53) points to startaddress

- Do I have to update afterwards some system variables? -> Yes, more (e.g. NEWPPC,E PPC,VARS,E LINE,X PTR,WORKSP)
  • check it in ROM-code (IX points to a header-block) - perhaps easier to use the ROM routines
- Which address range has to be written to MMC to save a complete program? ->
  • -> from addr. pointed by sysvar PROG to addr. (pointed by E_LINE) -1
Speccy_MEM.png
Speccy_MEM.png (11.19 KiB) Viewed 2669 times
- How do I switch form SLOW to FAST mode and back?
  • in BASIC: REM =>fast and REM =>slow - where "=>" is SHIFT+Y
    in asm: SW_FAST = call $054c and SW_SLOW = call $1296
SPONZY's RAM check is same as the Speccy's - the above can be a good solution "to 'protect' the upper 32K".

drBeep is right, no reserved registers in SPONZY

Regards,
Zsolt

ps: I will publish the source code with comments as well, as soon as possible. (few months :mrgreen: )

EDIT: the attachment was removed. Here is the final version of SPONZY
Last edited by zsolt on Mon May 28, 2012 9:03 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 » Tue Jan 03, 2012 11:32 pm

Thanks a lot for that information. I will try the new version at Saturday, when I am back from holidays ..

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

Post Reply