Page 4 of 11

Re: SPeccy ON the ZeddY

Posted: Mon Jan 02, 2012 1:11 pm
by dr beep
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.

Re: SPeccy ON the ZeddY

Posted: Mon Jan 02, 2012 1:58 pm
by siggi
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

Re: SPeccy ON the ZeddY

Posted: Mon Jan 02, 2012 2:20 pm
by dr beep
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?

Re: SPeccy ON the ZeddY

Posted: Mon Jan 02, 2012 3:23 pm
by siggi
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

Re: SPeccy ON the ZeddY

Posted: Mon Jan 02, 2012 3:30 pm
by dr beep
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

Re: SPeccy ON the ZeddY

Posted: Mon Jan 02, 2012 6:01 pm
by siggi
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

Re: SPeccy ON the ZeddY: IX/IY usage

Posted: Tue Jan 03, 2012 2:35 pm
by siggi
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

Re: SPeccy ON the ZeddY: IX/IY usage

Posted: Tue Jan 03, 2012 3:05 pm
by dr beep
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

Re: SPeccy ON the ZeddY

Posted: Tue Jan 03, 2012 11:15 pm
by zsolt
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 4949 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

Re: SPeccy ON the ZeddY

Posted: Tue Jan 03, 2012 11:32 pm
by siggi
Thanks a lot for that information. I will try the new version at Saturday, when I am back from holidays ..

Siggi