ZXpand ROM character set corruption

Discussions about Sinclair ZX80 and ZX81 Hardware
Post Reply
User avatar
bobs
Posts: 275
Joined: Thu Aug 27, 2009 10:49 pm
Location: Derbyshire, UK
Contact:

ZXpand ROM character set corruption

Post by bobs » Sat Jan 02, 2016 9:19 pm

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.

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

Re: ZXpand ROM character set corruption

Post by siggi » Sat Jan 02, 2016 10:19 pm

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
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
bobs
Posts: 275
Joined: Thu Aug 27, 2009 10:49 pm
Location: Derbyshire, UK
Contact:

Re: ZXpand ROM character set corruption

Post by bobs » Sat Jan 02, 2016 11:17 pm

Thanks Siggi, that makes sense. Hopefully I can find enough memory to duplicate the font into RAM for the affected games.

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

Re: ZXpand ROM character set corruption

Post by 1024MAK » Sun Jan 03, 2016 12:20 am

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

User avatar
bobs
Posts: 275
Joined: Thu Aug 27, 2009 10:49 pm
Location: Derbyshire, UK
Contact:

Re: ZXpand ROM character set corruption

Post by bobs » Sun Jan 03, 2016 12:42 am

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.

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

Re: ZXpand ROM character set corruption

Post by 1024MAK » Sun Jan 03, 2016 3:01 am

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

User avatar
bobs
Posts: 275
Joined: Thu Aug 27, 2009 10:49 pm
Location: Derbyshire, UK
Contact:

Re: ZXpand ROM character set corruption

Post by bobs » Sun Jan 03, 2016 2:21 pm

Thanks Mark, will give disabling the EPROM a go.

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

Re: ZXpand ROM character set corruption

Post by sirmorris » Thu Jan 14, 2016 8:10 am

^^ 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

Post Reply