Page 1 of 1

ZXpand ROM character set corruption

Posted: Sat Jan 02, 2016 9:19 pm
by bobs
I've just released 'CroZXy Road' for the 16K ZX81, and somebody has mentioned that there is graphical corruption when a ZXpand interface is present. This has been seen when using the EightyOne emulator, and I've narrowed it down to my game reading the font bytes from the ROM address 0x1E00 forward to display them enlarged on-screen when the game comes to the high-score entry screen.

Can anybody (SirMorris?) explain why this might be the case, and how to fix it? Is it that a shadow ROM is paged in?

(The same issue could probably be seen in the last few of my games, such as Rebound & U-Bend, as they both use a similar system for showing 'super-sized' font characters)

Bob.

Re: ZXpand ROM character set corruption

Posted: Sat Jan 02, 2016 10:19 pm
by siggi
AFAIK the rom character set is only available during REFRESH cycles, when the display is generated. It cannot be read by READ cycles, because then the ZXPAND rom is active, where that space is used for additional code. So a printer-routine would load the machine code bytes and print it out instead of the character set.

HTH Siggi

Re: ZXpand ROM character set corruption

Posted: Sat Jan 02, 2016 11:17 pm
by bobs
Thanks Siggi, that makes sense. Hopefully I can find enough memory to duplicate the font into RAM for the affected games.

Re: ZXpand ROM character set corruption

Posted: Sun Jan 03, 2016 12:20 am
by 1024MAK
There is a ZXpand command to disable it's internal EPROM once the file is loaded, which then allows the CPU to read the Zeddy ROM.

Of course, once the ZXpand EPROM is disabled, BASIC can no longer use the ZXpand commands.

Mark

Re: ZXpand ROM character set corruption

Posted: Sun Jan 03, 2016 12:42 am
by bobs
That sounds like a simpler solution to my problem Mark, but would the joystick interface still be available to me? That's the only functionality of the interface which is used.

Re: ZXpand ROM character set corruption

Posted: Sun Jan 03, 2016 3:01 am
by 1024MAK
I think the joystick can still be read, as that is accessed by your machine code talking to the PIC micro-controller. This was posted on the forum a while back, so a search may find it.

As to the instruction to load a program and disable the ZXpand EPROM, read this extract from the manual:
ZXpand manual wrote:LOAD "filename;X"
Once the program is loaded the overlay ROM is disabled and full access to the internal system ROM
is given. The overlay ROM remains disabled until the current session is ended with a hard reset (press
and hold) or power cycle.
The manual also says this:
ZXpand manual wrote:Programmatically disable the interface’s overlay ROM until the next reset:

Code: Select all

ld bc, %1110000000000111
ld a,$b0
out (c),a
Read the joystick port:

Code: Select all

ld bc, %1110000000000111
ld a,$a0
out (c),a
[some small delay, 10 clocks or so]
in a,(c)
Manual here

Mark

Re: ZXpand ROM character set corruption

Posted: Sun Jan 03, 2016 2:21 pm
by bobs
Thanks Mark, will give disabling the EPROM a go.

Re: ZXpand ROM character set corruption

Posted: Thu Jan 14, 2016 8:10 am
by sirmorris
^^ What Mark said. 100% correct. :ugeek:

What is not correct is the manual - the 'some small delay' needs to be longer than the suggested 10 clocks.

The OUT sets the interface reading the j/s input port and arranging the bits, whereupon the assembled joystick value is placed in the output latch for reading. The IN then reads the latch.

What I've suggested to people in the past is that they prime the port after reading. In other words read the port to get the value that was collected on the previous game frame, then start the collection to complete whilst going about the business of the current frame.

The only issue with this is that it will add a frame's worth of latency into the input. For some things this won't matter but i suppose that depends on the frame rate and acuity of the user's temporal perception ;)

Otherwise just do the OUT at the start of the frame then do some other things before doing the IN. Processing always takes the same time so if it works once it will always work.

C