Games from ROM

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
dikdom
Posts: 16
Joined: Sat Aug 12, 2023 12:10 am

Games from ROM

Post by dikdom »

Hello,

I would have two questions...
a) how to start a .p game from ROM?
b) What is the memory configuration in case of 32kB of internal/external RAM expansion?

Let me elaborate a bit:
a) what I do is that I allow to execute all the BOOT initialization code of the ZX81 and stop execution before going to UPPER. Then I load the .p byte stream to $4009 and continue with a SLOW/FAST call (well, before that call I have to push $0676 into stack, set $4000 to $FF and $4001 to $80 - this is what I saw in the emulator during normal LOAD). Unfortunately this works with some games, but doesn't with some others (jbracing - I'm not sure if this is the case because of my faulty WRX implementation or because of the faulty RUN implementation).

b) Let's say we have 2x16 kB RAM block. The first 16kB is mapped to $4000 to $7FFF. I know that reading in the /M1 phase (T1 and T2) the CPU must get the values from $4000-$7FFF when reading $4000-$FFFF. Also, the RAM must return valid data during /RFSH. But from where? When the CPU accesses $8000-$BFFF shall it read the first or the second 16kB? And in $C000-$FFFF the CPU always get the values from $4000-$7FFF?

This could be one possible solution. Is there any reason to do it differently?

Code: Select all

     \phase||T1-T2 (/M1)|T3/T4 (/RFSH)|/RD or /WR (after T4)|
accessing\ ++-----------+-------------+---------------------+    
$4000-$7FFF||$4000-$7FFF| $4000-$7FFF |     $4000-$7FFF     |
$8000-$BFFF||$4000-$7FFF| $8000-$BFFF |     $8000-$BFFF     |
$C000-$FFFF||$4000-$7FFF| $8000-$BFFF |     $4000-$7FFF     |
Thanks for any thoughts and ideas!
dr beep
Posts: 2080
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Games from ROM

Post by dr beep »

dikdom wrote: Tue Aug 15, 2023 8:28 pm,


a) how to start a .p game from ROM?
LOAD “”
b) What is the memory configuration in case of 32kB of internal/external RAM expansion?
#4000-#BFFF

Let me elaborate a bit:
a) what I do is that I allow to execute all the BOOT initialization code of the ZX81 and stop execution before going to UPPER.
????????
You only go to UPPER after a RAND USR
dikdom
Posts: 16
Joined: Sat Aug 12, 2023 12:10 am

Re: Games from ROM

Post by dikdom »

Thanks, but...
a) by
how to start a .p game from ROM?
I meant let's suppose I already copied a program from ROM (!) to the RAM ($4009-) during the boot-up sequence. In that case how to start a program with any user interaction.
In the meantime I've got my answer for that.

What is
RAND USR
?

In my question I was referring to the ROM routinge 'UPPER' and not a basic command.

b) thanks!
dr beep
Posts: 2080
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Games from ROM

Post by dr beep »

honestly,

I don't get your questions

first of all the ROM holds no games so it can copy them.

Second what is UPPER to you?

To me it is memory called to execute the screen.
User avatar
1024MAK
Posts: 5118
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Games from ROM

Post by 1024MAK »

In a standard ZX81/TS1000 (one with no modifications), there is no way to stop the ROM from running BASIC and the machine getting to the stage of printing K on screen and waiting for user input.

Are you talking about making a modified ROM (or equivalent)?

If you are talking about making a custom ROM (or equivalent), there is no need to ‘boot’ any part of the BASIC ROM, unless it’s actually a BASIC program you want to run. If this is the case, an example is the demonstration ROM that was produced (and is on here in a different topic). But that needs additional circuitry as it’s an expansion.

An alternative is to use an external ROM and switch out the (bank or page) the external ROM to replace the BASIC ROM in the memory map.

To BASIC, there is no difference between a 16K RAM pack / expansion and a 32K RAM pack / expansion. As the BASIC ROM is only written to recognise up to 16K.

PEEK, POKE, USR all do however work across the entire address range.

With some RAM packs/expansions, if you POKE certain system variables with new values, then do NEW, you can trick BASIC into using more RAM. However, there are some limitations.

It also depends on where in the memory map the extra RAM is positioned. There is no universal 32K expansion. Instead there are various different versions and variants. Some add RAM between 0x2000 and 0x3FFF. Some put the extra RAM at 0xC000 to 0xFFFF (but only to be used for data, cannot be used for executing machine code). And some do actually have RAM in the 0x8000 to 0xBFFF.

In a standard ZX81/TS1000 (one with no modifications), the memory decoding is very simple at the hardware level. This does make it confusing at the software level. Please read this topic to find out more about it.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
dikdom
Posts: 16
Joined: Sat Aug 12, 2023 12:10 am

Re: Games from ROM

Post by dikdom »

Sorry, I wasn't clear enough!
I already found my answer, but let me explain what and why I was looking for that.
So, I created a cheap cart that has 32kB RAM, 8MB serial flash ROM and a 64kB (parallel ROM). And a joy port, which is not relevant now.

So, I modified the boot ROM code and I step in after the memory initialization and I show the list of the games/programs stored on the 8MB flash. After selection with joy or keyboard the cart loads the program into memory and executes it.
In an early stage of the development I was a bit garbled how to start a program from my code, but finally I managed to do so. Even a 16240 bytes long program can be loaded.

During the development I figured out how to modify my ROM program (and PCB) to be able to load programs from SD card also, but that is also a side-track now. I'm waiting for the PCBs, they are in Germany somewhere now, hoperfully next week they'll arrive and I can tell you more about the project.
dikdom
Posts: 16
Joined: Sat Aug 12, 2023 12:10 am

Re: Games from ROM

Post by dikdom »

1024MAK wrote: Sat Sep 09, 2023 6:21 pm [...]
Are you talking about making a modified ROM (or equivalent)?
yes
If you are talking about making a custom ROM (or equivalent), there is no need to ‘boot’ any part of the BASIC ROM, unless it’s actually a BASIC program you want to run. [...]
I want to execute basic and ML programs as well, see my earlier comment for explanation.
[...]
It also depends on where in the memory map the extra RAM is positioned. There is no universal 32K expansion. Instead there are various different versions and variants. Some add RAM between 0x2000 and 0x3FFF. Some put the extra RAM at 0xC000 to 0xFFFF (but only to be used for data, cannot be used for executing machine code). And some do actually have RAM in the 0x8000 to 0xBFFF.

In a standard ZX81/TS1000 (one with no modifications), the memory decoding is very simple at the hardware level. This does make it confusing at the software level. Please read this topic to find out more about it.

Mark
Mark, thanks a lot for your response!

I wasn't aware of the memory layout explanation earier.. Anyway, I somehow figured that out.
So in the case of my cart this is how I solved it:
0000-3FFF:
- /RFSH high: code execution, external ROM active
- /RFHS low: character display, internal ROM active (ULA can control only the internal ROM)
4000-BFFF: 32kB RAM, continuously, Above $8000 only data access .
C000-FFFF: mirrorred of $4000-$7FFF memory area.
Reading RAM during the CPU's /M1 and /RFSH is enabled.

Normal mode, pseudo high-res and WRX high res games work. Loading from flash chip, from SD card works, actually I'm quite content with the result.

Dikdom
Post Reply