[Hector] I have been doing some coding

Cette catégorie traite de développements récents pour nos vieilles machines, applications, jeux ou démos... Amis programmeurs, c'est ici que vous pourrez enfin devenir célèbres!

Modérateurs : Papy.G, fneck, Carl

Répondre
Iapetus
Messages : 155
Inscription : 22 nov. 2012 15:36

[Hector] I have been doing some coding

Message par Iapetus »

Salut a tous,

During the last few days I have been doing some Hector Z80 coding.

Unfortunately I don't possess the real machine and I have been using the following emulators to check my code: VBHEctor4.1, MESS(MAME) and DcHectorv0.1.

I have been coding a sprite engine for a possible game.

I have one question question though and it is about interrupts as I am getting different behaviours when trying my code on the emulators.

When I use Halt to wait for the interrupt to kick in on DCHector and Mess, the computer stops at the Halt instruction and won't do nothing else but on VBHector it works...

I have found a way to make the code work on DCHector and MESS by adding the following code to my routine:

Code : Tout sélectionner

DI
IM 1
EI
I haven't read all of the french documentation so I might have missed something...

Can someone try my code on the real machine please?Send me a PM with your email and will send you the tape wave file.

Here is a video of the engine:
https://youtu.be/11yZW0kfz1Q

(note the video is going twice as fast, I don't know why :( but you have an idea of how it is working)

Thanks
MO5 - MO6 - TO8D - C64C - Timex TC2048 - Acorn Electron - Amiga 500
Iapetus
Messages : 155
Inscription : 22 nov. 2012 15:36

Re: [Hector] I have been doing some coding

Message par Iapetus »

While I wait for someone who know about z80 coding on the machine to answer my question above I have been busy with some gfx for the hypothetical game. :P
ovos.png
ovos.png (3.11 Kio) Consulté 4758 fois
MO5 - MO6 - TO8D - C64C - Timex TC2048 - Acorn Electron - Amiga 500
__sam__
Messages : 7923
Inscription : 18 sept. 2010 12:08
Localisation : Brest et parfois les Flandres

Re: [Hector] I have been doing some coding

Message par __sam__ »

Very nice graphics! cool 8)
Samuel.
A500 Vampire V2+ ^8^, A1200 (030@50mhz/fpu/64mb/cf 8go),
A500 GVP530(MMU/FPU) h.s., R-Pi, TO9, TO8D, TO8.Démos
Avatar de l’utilisateur
hlide
Messages : 3469
Inscription : 29 nov. 2017 10:23

Re: [Hector] I have been doing some coding

Message par hlide »

Question: why are you using "halt"? what for? There is no explanation, no context.

I'm not a specialist regarding Hector, but using 'halt' is a curious thing which should not be usually put in the hands of a "user".

As you probably know, you may have different sources for an interrupt. If you are using 'halt' to synchronize with a specific source, do you check which interrupt source resumes the execution from the 'halt' instruction?

Regarding the emulators, some may not be accurate due to their nature. You are probably using a "feature" which is not commonly used in Hector softwares.

So, first explain why/what for you need 'halt' and maybe you'll get more precise answers.

Regards.
Iapetus
Messages : 155
Inscription : 22 nov. 2012 15:36

Re: [Hector] I have been doing some coding

Message par Iapetus »

__sam__ a écrit : 01 déc. 2018 22:13 Very nice graphics! cool 8)
Thank you!
hlide a écrit : 01 déc. 2018 22:19 Question: why are you using "halt"? what for? There is no explanation, no context.

I'm not a specialist regarding Hector, but using 'halt' is a curious thing which should not be usually put in the hands of a "user".

As you probably know, you may have different sources for an interrupt. If you are using 'halt' to synchronize with a specific source, do you check which interrupt source resumes the execution from the 'halt' instruction?

Regarding the emulators, some may not be accurate due to their nature. You are probably using a "feature" which is not commonly used in Hector softwares.

So, first explain why/what for you need 'halt' and maybe you'll get more precise answers.

Regards.
I tried HALT to see if it would help sync with the screen refresh, like it is done on the ZX SPECTRUM; it was just a test, I haven't found anything about it on the docs I have about the Hector. There is a memory position where we can activate or deactivate different functions that are driven by interruptions but there is no mention of vsync. But then I found that discrepancy when handling Halt when using different emulators and decided to ask about it.
MO5 - MO6 - TO8D - C64C - Timex TC2048 - Acorn Electron - Amiga 500
Avatar de l’utilisateur
hlide
Messages : 3469
Inscription : 29 nov. 2017 10:23

Re: [Hector] I have been doing some coding

Message par hlide »

Ok, you were thinking to use 'halt' as a way to synchronize with V-sync.

Using 'halt' for such thing is no a good practice. 'halt' is used to make Z80 to idle until there is a task to do. Not to synchronize.

I'm not a Hector specialist so I don't know what the possible interrupt sources are. But there is at least one which tends to be common : a timer. And there could be asynchronous interrupts which may ruin the smoothness. From here, it seems there is a 20ms periodical timer: 50 Hz. But it is not clear if it is a hardware timer to emulate or it is just a emulator timer to emulate the 50 Hz refresh. But the author talks about interruptions so I guess there is an effect on 'halt' - at least on VBHector.

Maybe the other two emulators are not setting the interrupt mode to IM1 by default, which may explain why you need to do so initially, right?
Avatar de l’utilisateur
hlide
Messages : 3469
Inscription : 29 nov. 2017 10:23

Re: [Hector] I have been doing some coding

Message par hlide »

W_oo_d a écrit : 28 nov. 2018 13:28 Here is a video of the engine:
https://youtu.be/11yZW0kfz1Q

(note the video is going twice as fast, I don't know why :( but you have an idea of how it is working)

Thanks
What is going twice as fast? only the video? or the game running on the emulator?
Iapetus
Messages : 155
Inscription : 22 nov. 2012 15:36

Re: [Hector] I have been doing some coding

Message par Iapetus »

hlide a écrit : 01 déc. 2018 23:16 Ok, you were thinking to use 'halt' as a way to synchronize with V-sync.

Using 'halt' for such thing is no a good practice. 'halt' is used to make Z80 to idle until there is a task to do. Not to synchronize.

I'm not a Hector specialist so I don't know what the possible interrupt sources are. But there is at least one which tends to be common : a timer. And there could be asynchronous interrupts which may ruin the smoothness. From here, it seems there is a 20ms periodical timer: 50 Hz. But it is not clear if it is a hardware timer to emulate or it is just a emulator timer to emulate the 50 Hz refresh. But the author talks about interruptions so I guess there is an effect on 'halt' - at least on VBHector.

Maybe the other two emulators are not setting the interrupt mode to IM1 by default, which may explain why you need to do so initially, right?
Thank you for that but as I said previously 'halt' is used on the Speccy to wait for the interrupt (that runs at 50hz). It was just an idea to try it also on the Hector.
hlide a écrit : 01 déc. 2018 23:24 What is going twice as fast? only the video? or the game running on the emulator?
Only the video, I have to record it using another program. The one I used is not working correctly for when I replay the video the frame rate seems to be the double of the one from the emulator.
Maybe the other two emulators are not setting the interrupt mode to IM1 by default, which may explain why you need to do so initially, right?
At least on Mess I think it is IM 0, that's what gave me the clue to try to use the code setting IM to 1.
MO5 - MO6 - TO8D - C64C - Timex TC2048 - Acorn Electron - Amiga 500
Avatar de l’utilisateur
hlide
Messages : 3469
Inscription : 29 nov. 2017 10:23

Re: [Hector] I have been doing some coding

Message par hlide »

W_oo_d a écrit : 01 déc. 2018 23:31 At least on Mess I think it is IM 0, that's what gave me the clue to try to use the code setting IM to 1.
Yeah, normally the ROM should set IM to 1 explicitely as I believe a true Z80 is using IM 0 by default. But that's weird, the ROM should rely on the right IM to work properly.

Regarding screen refresh, I would poll the vsync to be sure to be aligned on it and not on a 50Hz timer which may not be aligned on vsync. Unless that "50Hz timer" is just the vsync feeded as an interrupt (and be the only one interrupt possible on Hector apart from NMI).
Iapetus
Messages : 155
Inscription : 22 nov. 2012 15:36

Re: [Hector] I have been doing some coding

Message par Iapetus »

hlide a écrit : 01 déc. 2018 23:53
W_oo_d a écrit : 01 déc. 2018 23:31 At least on Mess I think it is IM 0, that's what gave me the clue to try to use the code setting IM to 1.
Yeah, normally the ROM should set IM to 1 explicitely as I believe a true Z80 is using IM 0 by default. But that's weird, the ROM should rely on the right IM to work properly.

Regarding screen refresh, I would poll the vsync to be sure to be aligned on it and not on a 50Hz timer which may not be aligned on vsync. Unless that "50Hz timer" is just the vsync feeded as an interrupt (and be the only one interrupt possible on Hector apart from NMI).
It would be nice to know if it is possible to poll the vsync on the Hector. I do that on the Thomson machines to sync with the screen.
MO5 - MO6 - TO8D - C64C - Timex TC2048 - Acorn Electron - Amiga 500
nicolho
Messages : 409
Inscription : 10 nov. 2016 16:53

Re: [Hector] I have been doing some coding

Message par nicolho »

I would'nt have thought to join such conversation, but I feel that too much unverified allegations have been made here... Coincidentally, last days while porting an old emulator of the "best selling of all time Z80-based home video game console" :) , I had to rewrite the CPU interrupt handling and related instructions, and I can say that roughly 100% of the 300 commercial games for it start with these bytes : F3 ED 56 (DI and IM 1)!

Indeed Interrupt Mode 0, while the default, is pratically never implemented, and it is the sole source of hardware interrupt, usually triggered at the end of each frame, so coders can take advantage of the interrupt routine to do things like to start offscreen VRAM writes during VBLANK.
hlide a écrit : 01 déc. 2018 22:19Using 'halt' is a curious thing which should not be usually put in the hands of a "user".
(...)
Using 'halt' for such thing is no a good practice.
Are you a direct descendant of Moses ?? :) Because it really sounds like the "Ten Commandments of HALT"... :cry: Do you have any proof or example of such categorical statements ? (or did the God of Z80 whispered them to you in your sleep ? :mrgreen:

My test rom this week was a very famous and demanding game (one of the bestsellers for this platform, codename : "Le Retour du Hérisson Bleu" :wink: ) and (like W_oo_d does) it uses HALT to wait for next VBLANK interrupt, in this case, to show a progressive, synchronised frame by frame, fading to black between each level and presentation screens.
So it is perfectly valid to use it when your code has, at some point, nothing else to do than to wait for the next interrupt that will "wake" the CPU, with the benefit of some energy efficiency... and anything that help to "développement durable" seems like a totaly recommanded pratice ! :)
hlide a écrit : From [linked message], it seems there is a 20ms periodical timer: 50 Hz. But it is not clear if it is a hardware timer to emulate or it is just a emulator timer to emulate the 50 Hz refresh. But the author talks about interruptions so I guess there is an effect on 'halt' - at least on VBHector.
(...)
Unless that "50Hz timer" is just the vsync feeded as an interrupt (and be the only one interrupt possible on Hector apart from NMI).
If it's not clear, then why do you just guess (or make assumptions only based on a few vague words like "the 20ms interrupts" in linked message) instead of looking for the real answer ?
You probably know that http://hectorvictor.free.fr/ provides a lot a reference documentation in its "Literature" section , like the schematics (that you seem able to analyze the circuit, like you do with with IO addressing on forum.sharpmz.org) of the Hector HR, so could have check first.

I spent 10 minutes doing just that, and I can already see that the NMI input is disabled (only pulled up in 'high' state) on schematic 4 :
source : http://hectorvictor.free.fr
source : http://hectorvictor.free.fr
extrait des schémas techniques Hector HRX - page 06.jpg (99.3 Kio) Consulté 4686 fois
On schematic 6A, named "Comptage Video" you can see it is articulated around a counter which is probably dedicated to scan the video RAM, along with some logic that uses this addressing sequence to get dividers by 76 and 103 (!) to obtain and trigger VSync, and you can even see this formula of its period (so we can even tell that the exact framerate is approximately 50.57 Hz ! 8) ) :
source : http://hectorvictor.free.fr
source : http://hectorvictor.free.fr
extrait des schémas techniques Hector HRX - page 09.jpg (33.2 Kio) Consulté 4686 fois
Avatar de l’utilisateur
hlide
Messages : 3469
Inscription : 29 nov. 2017 10:23

Re: [Hector] I have been doing some coding

Message par hlide »

Je n'ai pas d'Hector et je n'ai pas l'intention de gaspiller mes deux seules journées du weekend à faire des recherches dessus puisque c'est les deux seuls jours où je peux être chez moi et faire quelque chose que j'aime. Tu l'as fait, très bien. W_oo_d pourra te remercier mais il aura fallu que ce soit au prix d'un "harcèlement" sur ma personne. Donc si j'ai compris, il faut que j'intervienne sur un sujet, pour que tu interviennes et apportes la réponse en m'égratignant au passage ? tu as un problème personnel à régler ? parce que moi ça ne m'intéresse pas de continuer avec toi sur cette base là.

Ah au passage. L'instruction 'halt' est faite pour mettre au repos le CPU quand ce dernier n'a plus rien à faire et ce quelque soit les architectures. Que des consoles ou des micro-ordinateurs aient détourné son usage pour attendre sur un rafraîchissement est un détournement acceptable dans la mesure où la seule interruption qui peut le faire sortir de son repos est bien celle du rafraîchissement. Et je ne pense pas avoir tort. Pour le reste, je me contrefiche de ce que tu peux dire.

A bon entendeur salut !
nicolho
Messages : 409
Inscription : 10 nov. 2016 16:53

Re: [Hector] I have been doing some coding

Message par nicolho »

Euh..faut arrêter la parano, on dirait que tout tourne autour de toi. Seulement tu as sans doute remarqué que toi et moi faisons partie des habitués qui postent presque quotidiennement (ça se limite pas au weekend, il me semble tu as posté plusieurs fois certains soirs) et que nous intervenons tous deux dans divers sujet de discussion.

Maintenant, tu as dit beaucoup de chose sur ce fil hier soir, je relis ça ce matin et comme je l'ai dit (en anglais) je réagis parce que le contenu des messages et les réponses faites m'interpellent, j'ai d'ailleurs pris la peine de préciser en préambule de mon unique message pour quelle raison j'intervenais. Alors j'essaye de manier un peu l'ironie (parfois mordante) quand je ne suis pas d'accord, mais toujours poliment et avec des arguments techniques.

Je n'interviens pas systématiquement, et ça n'a rien de personnel, si j'ai un certain nombre de points de désaccord ou une manière divergente d'envisager plusieurs idées émises dans la suite de tes messages précédents. J'ai aussi eu des réactions positives à tes interventions, notamment les photos et tes essais d'oscilloscope... Enfin ce n'était pas spécialement réciproque, d’ailleurs je viens de compter : dans ces échanges récents, sur une douzaine de message chacun, j'ai utilisé environ 15 fois le pronom "tu" pour m'adresser à toi (comme je le ferai sympathiquement avec n'importe quel autre participant) contre une seule fois pour toi, et mes remerciements sont restés à sens unique, malgré les nombreuses informations apportées. Au final, il faudrait aussi voir la poutre, tout ça...
hlide a écrit : 02 déc. 2018 11:53 je me contrefiche de ce que tu peux dire. A bon entendeur salut !
Ah sympa ! Donc tu veux être entendu mais pas entendre... Bon, je posterai quand même mon avis, enfin ça explique beaucoup de choses, et par exemple sans doute pourquoi je n'ai finalement eu droit à aucune réaction de ta part concernant mes recherches et compte-rendus sur les Sharp (enfin si je comptais vraiment là-dessus, je n'écrirais pas grand chose :mrgreen: )
Iapetus
Messages : 155
Inscription : 22 nov. 2012 15:36

Re: [Hector] I have been doing some coding

Message par Iapetus »

nicolho a écrit : 02 déc. 2018 11:11 [...]
I spent 10 minutes doing just that, and I can already see that the NMI input is disabled (only pulled up in 'high' state) on schematic 4 :
extrait des schémas techniques Hector HRX - page 06.jpg
On schematic 6A, named "Comptage Video" you can see it is articulated around a counter which is probably dedicated to scan the video RAM, along with some logic that uses this addressing sequence to get dividers by 76 and 103 (!) to obtain and trigger VSync, and you can even see this formula of its period (so we can even tell that the exact framerate is approximately 50.57 Hz ! 8) ) :
extrait des schémas techniques Hector HRX - page 09.jpg
Thank you nicolho, I never thought of looking at the 'schémas'! I need to learn to understand them as they are very useful. :) I looked into some books and magazines I could find in the internet but of course I I didn't have the time to read them through I just skimmed sections I thought I could find some information on those topics.
MO5 - MO6 - TO8D - C64C - Timex TC2048 - Acorn Electron - Amiga 500
Avatar de l’utilisateur
hlide
Messages : 3469
Inscription : 29 nov. 2017 10:23

Re: [Hector] I have been doing some coding

Message par hlide »

nicolho a écrit : 02 déc. 2018 12:26
hlide a écrit : 02 déc. 2018 11:53 je me contrefiche de ce que tu peux dire. A bon entendeur salut !
Ah sympa ! Donc tu veux être entendu mais pas entendre... Bon, je posterai quand même mon avis, enfin ça explique beaucoup de choses, et par exemple sans doute pourquoi je n'ai finalement eu droit à aucune réaction de ta part concernant mes recherches et compte-rendus sur les Sharp (enfin si je comptais vraiment là-dessus, je n'écrirais pas grand chose :mrgreen: )
Tes interventions concernant des aspects techniques sur les SHARP sont sympas et m'impressionnent même - j'aurais aimé ce même niveau sur le forum de SHARPMZ qui manque cruellement à ce sujet. Je t'en remercie même si ça te paraît tardif. Là-dessus, je n'ai vraiment aucun soucis. Là où j'ai un soucis, c'est que systématiquement en préambule, tu me rabâches sur le manque de source : ça n'a rien d'amical à mes yeux, c'est devenu une attaque en règle presque personnelle. Laisse moi t'expliquer : je ne suis pas électronicien, je ne connais pas tous les termes exactes qui m'aideraient à la recherche, et je ne sais pas lire TOUS les schematics. Je débute, vraiment. Seulement j'ai un travail qui est à 50 bornes de chez moi qui fait que je n'ai que deux jours par semaine à consacrer à ça parce que je ne fais pas l'aller-retour tous les jours, donc il est normal que mes recherches n'aboutissent pas systématiquement à des informations pertinentes surtout quand je ne suis pas certain de ces informations - sans parler du fait que je n'ai pas assez de temps pour me former à attaquer des projets plus ambitieux comme je le voudrais. Par ailleurs, je m'occupe aussi de mes Amiga mais je n'en parle pas trop ici.

J'ai fait confiance à Karl May (auteur du site originel sharpmz.org) à tord parce qu'il me soutenait que l'on ne trouve plus le connecteur nécessaire au bus d'expansion du Z80. Et depuis, j'ai droit à cette longue litanie et souvent une interprétation erronée de mes interventions (ta première intervention sur le signal signal vidéo monochrome MZ-800 est un criant exemple : cette intervention aura certes eu au moins le mérite de faire ressortir le Hantek qui au final fonctionne bien sur un Windows 10). Mais là j'en ai tout simplement marre.

Concernant Hector, je n'avais aucune envie de faire une recherche. J'ai été juste interpellé par l'usage détourné d'une instruction et j'invitais implicitement l'auteur à vérifier par lui-même. Point barre.
Répondre