Page 1 of 2

Hi Everyone

Posted: Fri Aug 04, 2023 4:31 pm
by Baggey
Ive been writing Emulators as a little hobby of mine. I use BlitzMaxNG which is very fast and capable.

Ive just made a ZX81 Emulator :mrgreen: and need to know about the .p File format.

I can't find anything that gives a break down of the file like loading registers where the program is loaded to and how to access its start address.

Oh you can see my emulators over at https://www.syntaxbomb.com/showcase/zx8 ... ying-ball/

My ZX81 is showing a blank Screen currently but i've moved on a bit from there recently! I need to make a new VIDEO but dont want too untill i have .p Files loading in!

I found the Screen very tricky to do because it is constantly moving around as you type in your Basic Program. Which ive sorted now by finding where the DFILE is and if it's changed from the last Valid DFILE i recalculate where the screen address are again which seems to be working a treet! :D

Kind Regards Baggey

Re: Hi Everyone

Posted: Fri Aug 04, 2023 7:46 pm
by 1024MAK
Hello and welcome to our forum Baggey!

:D :D :D

Some very useful information here ;-)

I hope you enjoy this forum :D

Mark

Re: Hi Everyone

Posted: Fri Aug 04, 2023 9:31 pm
by dr beep
.p is just a memorydump to be loaded at #4009.

Re: Hi Everyone

Posted: Fri Aug 04, 2023 9:41 pm
by dr beep
On a modern computer you can easily emulate a ZX81 and its weird screen.

Do you want to go for perfect emulation with hires and psuedo hires then the mentioned link will give you much info.

My emulator on the ZX Spectrum needed a balance between speed and perfection so lowres is only possible.
This is also done different from the ZX81 but it is good for an emulator on the ZX Spectrum.

Re: Hi Everyone

Posted: Fri Aug 04, 2023 9:48 pm
by dr beep
LOAD will make the ROM go to #340
After loading the routine exits at #1FC with a screenupdate.

https://k1.spdns.de/Vintage/Sinclair/80 ... ra%29.html

Re: Hi Everyone

Posted: Sun Aug 06, 2023 10:12 am
by Baggey
dr beep wrote: Fri Aug 04, 2023 9:31 pm .p is just a memorydump to be loaded at #4009.
Thankyou for that it worked a treat! shame the .z80 .sna arn't that simple. I want to emulate as much as i can :shock:

I too have a ZX Spectrum Emulator ive written :P

Another thing ive found strange is the COPY of the shadow ROM. It dosent seem to matter wether its there or not. I suppose there is going to be a piece of software that use's it though.

Enabling write's down to 8192 seems to work okay but this has an effect on the NEW command writting down passed 16384 which destroys anything you would of had there! Ive been looking in to the NEW routine in ROM but haven't sussed what to alter to stop this yet! :roll: So for now im stopping writes into Shadow Rom below 16384. I know ill need to allow this i think latter for Quiksilva UDG routines and other Devices latter.

Sound is some what of a mistery still to me but id like to emulate ZONX and the AY. Still looking for info or code to give me an in site on how this is done.

Hi res graphics is something i definatly want to look into as well!

Im also having timing issues not quite sure how the HALT works exactly in the ZX81. Also im using a delay loop after 16000 TCycles have happend but this seems to slow down to much and make the keyboard Laggy. I seem to think there's more to do with timming delays when the ROM writes to the screen. In my BlitMax Spectrum Emulator 1 timeing loop delay after 69888 works but i havent emulated memory contention delay which seems to effect a few games. But thats another Story.

I also think some of my z80 opcodes arn't 100% but i suppose they never will as it's an emulator id like to find a .P file for testing all Opcodes and flags.

Im almost at the point of releasing a Video which ill post a link to on SyntaxBomb.

Eventually id like to use the emulator to inject your own code in and run basic at PC speeds even my own Language a bit like Z80 Machine code but written in Basic format with Macro routines for the overhead of z80 code needed. Like a collection of Routines under new ZX81 Commands. Anyway that's a BIG wish.

Im also looking for an article on adding your own Z881 Commands. But this will need interrupts. In code i cant see the ZX81 jumping to interrupts like th ZX spectrum does!? Or is this HARDWIRED in the ZX81 forcing jumps to interrupts?

I have FULLSCREEN working but i cant capture that in my DEMO's .Im stuck with 1920,1080 if people want to use my emulators in the future. There is full Memory view live and stepping so you can run through the z80 code as each instruction is Ran and see the effects on FLAGS. It's also a great learning tool by seeing how the z80 instructions actually work, as ive commented them heavily. I needed todo that so i could learn myself.

Kind Regards Baggey

Re: Hi Everyone

Posted: Sun Aug 06, 2023 11:22 am
by dr beep
Baggey wrote: Sun Aug 06, 2023 10:12 am
I too have a ZX Spectrum Emulator ive written :P

My ZX81 emulator(s) run(s) on a 48K ZX Spectrum
Another thing ive found strange is the COPY of the shadow ROM. It dosent seem to matter wether its there or not. I suppose there is going to be a piece of software that use's it though.
When no memory is there it reads first bank it is from.
So reading 8K=16K is like reading 0K-8K ROM.

Same in RAM.1K RAM will read mirrors when reading higher bank.
I use this trick to set SP in 1K games at higher bank where in 1K it is set in 1K bank.
This way I have a larger stack when that game loads in my emulator since my emulator is using a larger stack than the real machine. Smaller stack is possible but it would slow down my emulator.

Same problem otherway around I had when I was running my 1K hires games on a 48K ZX81.
With 48K RAM it read the real address where I never coded anything. To make my games run on a 48K machine
I needed to copy the game into the 48K range.


Im also having timing issues not quite sure how the HALT works exactly in the ZX81.
HALT will fill a line with spaces until next intrupt appeaers at #0038
I also think some of my z80 opcodes arn't 100% but i suppose they never will as it's an emulator
On a fast PC this is no argument.
id like to find a .P file for testing all Opcodes and flags.
There something like this for ZX Spectrum.... need to seek for it.
Im also looking for an article on adding your own Z881 Commands. But this will need interrupts. In code i cant see the ZX81 jumping to interrupts like th ZX spectrum does!? Or is this HARDWIRED in the ZX81 forcing jumps to interrupts?
Even on the ZX Spectrum this is not done by intrupts but by errorcodes.

Re: Hi Everyone

Posted: Mon Aug 07, 2023 12:12 pm
by Baggey
HALT will fill a line with spaces until next intrupt appeaers at #0038
Right i wondered how when the DFILE read $76 and then another 24 x $76 values how id get the 32 Spaces!?

As im doing 16K my DFILE it's always expanded! I check the Values of the DFILE and recalculate when it's changed to another area. So my screen isn't corrupted.

On my Spectrum emulator when i get to 69888 TStates. I trigger an interrupt and run it. ie, if IFF1 enabled and check for IM1 or IM2.

At the moment im not triggering them? I know when i get to 16000 TStates in SLOW mode an interupt should happen.
But it's is used to calculate characters so IM2 cant happen on a ZX81? So i instead i use only IM1 and go to $0038? I suppose i could always just try this?

Forgive me but i have to ask. Are you saying everytime a line to the screen is written we wait 16000 TStates and then write another line?
This i suppose would slow my emulation down and stop it being Pulsey or Laggy.

I think it's time todo my other video so you can see where im at. Any ideas or info is always appreciated! if we knew everything then we wouldn't have to learn. :?

Kind Regards Baggey

Re: Hi Everyone

Posted: Mon Aug 07, 2023 2:41 pm
by 1024MAK
I trust that you know that /INT is connected to address line A6?

And that the display code uses the R (refresh) register in an unconventional manner.

This and the circuitry around the /WAIT and /HALT pins are used by the display system.

Mark

Re: Hi Everyone

Posted: Tue Aug 08, 2023 11:13 am
by Baggey
So Finally after the penny drops ive managed to get the DFILE Displaying on Screen. My timing is way off and no interrupts triggering!? i show a quick basic program running and load a game in.

My Display isn't working correctly and the aliens aren't dropping to the floor? This could be because im not triggering interrupts or because the display timing isn't correct they may be linked to this.

In the Memory display you can see a ROM Shadow which dosen't seem to matter if it's there or not!?
It also shows the expanded DFILE and how it moves around in memory when inputting a Basic program.

Any hints tips on how to improve my DFILE emulation and how interrupts truly work on the ZX81. For an early computer it's proved very tricky just to Emulate this far!

Here's a Video to see my progress. https://youtu.be/ZiGx6AKpCMo

Kind Regards Baggey