Re: Different copying methods
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Sep 08, 1997
- 758 views
Ralf Nieuwenhuijsen wrote: > > Why the difference...?? > In the ASM, i think it should ask something like: > Is the value of the source memory a zero? yes-don't copy no-copy > or (source see-through effect above)(dest s.t. eff. > beneath) > Is the value of the dest memory a zero? yes-copy no-don't copy Here's what (I think) the code uses: Normal copy: MOVSB -- move a byte from source index to dest index See through copy: INSB -- get a byte from the source index if the byte read is zero then, OUTSB -- send the byte to dest index else INC EDI -- don't send it, but skip over that spot Destination see through: CMP BYTE PTR [EDI], 0 --compare the byte at dest index to zero if it was 0 then INC EDI -- skip over both INC ESI else MOVSB -- move a byte from source index to dest index As you can see, the Dest see thru copy has to do an extra check before it can do anything else. It has to read the destination memory and then test it, and that value isn't used again and effectively wasted, unlike the see through copy where the byte to be tested can be tested and then used again. And the normal copy is the fastest, it's just one instruction and doesn't have to do any tests. > Is it me not knowing ASM at all... or could this be overcome be an > optimization ?? > Please Micheal Bolin, tell me why... > An other request which would make stuff a *bit* faster would be to a new > command (4) to switch to the bank given in the next byte. > And what about a command (5) which would activate a wait_retrace? > > And as last... > the wait_retrace code by Pete Eberlein first waits for a wait retrace to > begin.. and ends.... it doesn't sound very logically to me... can't we > just only wait until it begins.. The only way to detect if a retrace is occurring by testing a bit read from a video register (#3DA). If bit 4 is on, then a the monitor is in the process of being refreshed from video memory, (a vertical retrace). If the bit is off, then the monitor is not doing anything, and it is okay to write to video memory. There is no easy way to tell where the monitor is on a retrace. The only way to know for sure where what the monitor is doing is to wait for the point where the bit changes from on to off. If we only test to see if the bit is off, the monitor could start a refresh at any time during a write to video memory. To make sure that a full length of time is available between refreshes, we must do the extra check. The wait_retrace code does this: -- a retrace could be in any state at this point: -- occurring, so we just wait for it to stop -- not ocurring, we don't know when it will start again while a retrace is not occurring end while -- a retrace is occurring, or just started while a retrace is occuring end while -- a retrace has just ended -- from here on, we have the full length of time -- between retraces to write to video memory See also my post "Re: Graphics mode 19 update rate" on 1 Sept 97. > we aren't gonna catch up with the video-refresh... You are right, we can't keep up with the video refreshes, we just have to make sure that we stay in between them. You will probably have to have a second timer so that the number of retraces missed stays constant. Otherwise your display rate might vary, depending on how much processing had to be done between frames, and this will affect the overall game speed. > Maybe some1 knows a way to handle the video refreshes manually (just > start one after we finished drawing :) There is a way to disable and disable video logic, sortof simulating a retrace. But I'm not sure you could do it fast enough to keep the screen from badly flickering. -- _____ _____ _____ ________ /\ \ /\ \ /\ \ / \ \ / \____\ / \____\ / \____\ / _ \____\ / / ___/_ / /____/ / / ___/_ / / \ |____|/ / /\____\ / \ \ / / /\____\ \ \_/ / / \ \/ / ___/_\ \ \ \ \/ / ___/_ \ /____/ \ / /\ \\/\ \ \ \ / /\ \ \ \ \ \ \/ \____\ \ \ \ \ \/ \____\ \ \ \ \ / / \ \____\ \ / / \ \____\ \ / / \ / / \ / / \ / / \ / / \/____/ \ / / \/____/ \/____/ \/____/