A.D.A. Amiga Demoscene Archive

        Welcome guest!

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / LoadView(NULL) can be avoided (I think)

 

Author Message
TheDarkCoder
Member
#1 - Posted: 9 Dec 2004 15:56
Reply Quote
hello

recent questinos posed in other threads, plus the discovery that my startup code was buggy becuse the WAitTOF (which follows LoadView) break the Forbid state, made me think about the LoadView(NULL) issue. And I think that nowadays, it's not necessary to use it in startups.
I want to explain why in detail, so if there is some bug in my reasoning, you can correct me! (but I started a new topic because it can be long).

First of all, why the LoadView? Back to the OCS- AmogaOS 1.2 era, C= was rather happy that people used to code by killing AmigaOS and taking direct control of the hardware. Infact, in that way, people could use all the incredible hardware power, and produce wondeful games &demos that helped selling the machines. To help coders, they even provide legal OS functions and methods to disable multitasking and interrupt (Disable and Forbid), to take control of the blitter (OwnBlit), of the audio, the CIA (through the various devices and resources). That is a very strange thing for an OS, I am preatty sure that no other OS for personal computers allows to do this (maybe it is possible on embedded devices: don't know).
Unfortunately, they did't provide a safe way to take control of the screen.
However that was no big deal: at those time you simply set up your own copperlist and put what you want in registers. To return (but usually games didn't return) to the OS,you just reload the view. At that time, there was no need to do LoadView(NULL).
Then ECS arrived, which added new hardware registers for the video. The old software, not aware of new screenmodes, failed. So, they realized that a way to take control of the video without knowing all the details of the video chip was needed. They decided to use LoadView(NULL). Note that the LoadView function already existed, but before OS 2.x, LoadView(NULL)
did nothing. But what exaclty does, starting from 2.x, LoadView(NULL).
I guess there is nothing magic in this function, that if you don't do it the Amiga shutdown immediately. Simply, LoadView(NULL) reset all video registers to a well-known state, namely a simple PAL screen (maybe NTSC for US Amigas?? doesn't matter). They strongly advised to use it before taking control for 2 reasons:
1) It is more confortable to reset all register with a single function callrather than resetting one by one, but most importantly...
2) it allows you to reset registers even if you don't KNOW them!!
Suppose, for example, that the wonderful AAA is introduced, providing
an amazing Holographic video-display, controlled by register BEAMCON1. BEAMCON1 has 1 bit: if 1, the Holographic mode is enabled, otherwise it is de-activated and the bitplanes are sent to the traditional 23-pin video port. A demo made in 92, when only AGA was available could not know the register BEAMCON1, so would have been unable to set BEAMCON1 to 0. BUT, if that demo would have called LoadView(NULL), the version of LoadView shipped with Kickstart 4.0 which would have been shipped together wit AAA machines, would have known BEAMCON1 and reset correctly the register.

Of course, of the two reasons, the most important was #2, i.e. it allowed future-compatibility. Sadly, we all know how things have worked, there was no AAA, no kickstart 4.0. Even though there are new hardware-box which claims to be "new Amigas" (I don't consider them, but that's not the point) these are completely different, and run the old software in emulation, so in a way or another they have to emulate also AGA.
So, I think reason #2 idoes not make sense anymore. And, as I said, #1 is just a shortcut, but you can avoid it by resetting registers by yourself.
In this way, you code is just a bit more elaborate, but you avoid the
problem of the WaitTOF, which re-enable multitasking allowing other tasks to change the view again after your LoadView(NULL) and before you disable (again) multitasking. That problem is unlikely to occur, but if it does then your code fails.

I think that without LoadView(NULL) and a carefull reset of ALL AGA registers, a demo can acquire control of the video in a 100% safe way.
I don't care at all about "new Amigas", so...
Clearly, you are 101% sure if you do BOTH LoadView(NULL) AND then reset all AGA registers by yourself.

What do you think??? :-)
Cyf
Member
#2 - Posted: 9 Dec 2004 17:16 - Edited
Reply Quote
yes, sure.
some of my olds intros coded on an old ocs a500 works fine on a1200, even on 060 - I made whdload for some of my prods, and they works without lot of modifications.
my first startup code doesnt use LoadView, only forbid, save syscop1 from gfxbase, save registers, disable, stop ints/dma and setup new int/copper and enable new int/dma.
but sometimes under WB3, some problems appears with interrupts(no anim, no sound) and display if aga enable (ecs compatibility missing) but not in NonDos.
z5_
Member
#3 - Posted: 19 Dec 2004 09:29
Reply Quote
Can't say if it is necessary or not, but it was really well explained!
xeron
Member
#4 - Posted: 23 Dec 2004 13:07 - Edited
Reply Quote
LoadView(NULL) is NECESSARY for ONE simple reason. If you have a graphics card and AGA on the same monitor, this will guarrantee that the graphics card screen will be switched out.

Also, its perfectly simple to do LoadView(NULL) and two WaitTOF()s before disabling multitasking.
TheDarkCoder
Member
#5 - Posted: 23 Dec 2004 13:35
Reply Quote
@xeron ah, ok, this is reasonable. I never had a gfx card. Is the LoadView(NULL) patched by the CyberGFX or the card's drivers?
xeron
Member
#6 - Posted: 23 Dec 2004 13:46 - Edited
Reply Quote
I guess it must be patched by the RTG system, since it is at the LoadView() command that all P96 and CGX screens become disabled, regardless of the card.
krabob
Member
#7 - Posted: 24 Dec 2004 10:28
Reply Quote
I don't remember everything, but there was a problem (another) with using AGA with commodore's multisynchro monitors: You could have WB using AGA with strange vertical frequencies with modes dblntsc,dblpal, multiscan, productivity. most AGA pal/ntsc demos known with "a clean startup" couldn't be launched from workbench configured like these (and i'm speaking about 1992 hardware here.) Also, returning to workbench is again another problem. some startups open a quick empty 2 color pal intuition screen to set a pal mode to avoid this, and close the pal screen just before quitting.
TheDarkCoder
Member
#8 - Posted: 25 Dec 2004 10:19
Reply Quote
@krabob: I don'see the problem,here. You can detect that your demo is running on a AGA machine and reset the video mode to PAL using the appropirate registers (BPLCONx, BEAMCON0). The problem with gfx card is that to switch them off you have to use the OS. I would say that those demos do not have good startups

 

  Please log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0