Deja Vu #05
31 мая 1998

CODING - Using a stack interrupt enable.

<b>CODING</b> - Using a stack interrupt enable.
SoundTrack: SECTOR / SERIOUS S.G. '97 (CMG98)
__________________________________________


(C) RLA / CRG
__________________________________________



           Stack Usage

       When resolving PREREYVANIYAH



   It is no secret that for fast manipulation
with graphics in games and, especially, in the demonstrations 
are commonly used commands stack. With their help, you can 
achieve the greatest rate of work with graphics. However, the 
steeper the effect, the longer it takes. There may be occasions 
when effect does not have time to work out 69,888 cycles

and an interrupt occurs. Return address
discarded onto the stack and irreversibly damages
contained underneath the information. But not all
lost. We consider several cases as
You can save the data and work with
stack enabled interrupts the second
kind.


   1. If there is a clearing or filling the screen with any 
data, it is not so scary, because when you return from interrupt

PUSH HL continue the cycle and the return address
will be overwritten by the required data.


   1.1 It is possible that the stack will be equal to 4000h
and the return address will be lost, but this
case can be controlled if you know
address those points in which this can happen and go there not 
to RET'u and JP ADDRESS. 


Example:

        LD SP, # 4020, net the most

        LD HL, # 0000 top line

        PUSH HL; in the screen

        PUSH HL

        PUSH HL

        ... * 16 times

        PUSH HL

        PUSH HL
ADR1 LD SP, (SAVESP)

        RET



   The latter case is possible if the interruption wedged 
between the teams PUSH HL and LD SP, (SAVESP). Handler 2 (!) 
Interrupts in this case would look like: 


        ORG # BFBF
INT2 DI

        LD (TOSP +1), SP

        LD SP, INT2-1

        PUSH HL

        PUSH DE

        PUSH BC

        PUSH AF

        PUSH IX

        EXX

        EX AF, AF

        PUSH HL

        PUSH DE

        PUSH BC

        PUSH AF

        PUSH IY



        LD HL, (TOSP +1)

        LD DE, - # 4000

        ADD HL, DE

        LD A, # C9; RET

        JR C, OK

        LD A, # C3; JP

        LD (TO_RET), A



        ... treatment interruption

        POP IY

        POP AF

        POP BC

        POP DE

        POP HL

        EXX

        EX AF, AF

        POP IX

        POP AF

        POP BC

        POP DE

        POP HL

        EI
TOSP LD SP, 0
TO_RET DB 0

        DW ADR1



   2. There is another insidious case where
data through the stack will not be recorded, and
read. Most often it is consumed,
when the screen is moving most of it
Part (TRASH DEMO, ART'98, all sorts of intros to the games). In 
memory of pre-created great sprite and displayed on the screen 
roughly the chain of bytes: 


       POP HL

       LD (# 4000), HL

       POP HL

       LD (# 4002), HL

       ...

       POP HL

       LD (# 57FE), HL

       LD SP, (SAVESP)

       RET



   In these programs, part of the screen
time to exchange a per interrupt,
and this problem does not arise, but there were
cases, when running a single effect, and then
need to throw the top window with the wishes of
or GTX'ami. If an interrupt, then
the stack is dropped again return address
and the sprite will be "permanently damaged.
It is in such a case appealed to me
one of my friends coder. After some
time the problem was solved. Its effects
worked in the interrupt enable, and
graphics are not spoiled.

Processor:


        ORG # BFBF
INT2 DI

        LD (TOSP +1), SP

        LD SP, INT2-1

        PUSH HL

        PUSH DE

        PUSH BC

        PUSH AF

        PUSH IX

        EXX

        EX AF, AF

        PUSH HL

        PUSH DE

        PUSH BC

        PUSH AF

        PUSH IY

        LD HL, (TOSP +1)

        LD E, (HL)

        INC HL

        LD D, (HL)

        LD (_JP +1), DE

        ... treatment interruption

        POP IY

        POP AF

        POP BC

        POP DE

        POP HL

        EXX

        EX AF, AF

        POP IX

        POP AF

        POP BC

        POP DE

        POP HL
TOSP LD SP, 0

        PUSH HL; Record

        POP HL; Adjustment stack

        EI
_JP JP 0



   Consider the possible cases when an interrupt can occur:


   a) between the teams and POP HL LD (NN), HL
Reads a byte in register HL
and before returning to the team will be recorded
PUSH HL.



   b) between the commands LD (NN), HL POP HL and
data again are in the HL and recover the same manner.

   It is worth noting that the return from the handler will 
always be performed by direct transition.


   I note that demonstrations such workarounds tricks with the 
stack I have not met. 

   I hope that this paper will reduce the work of some of your 
effects on the excess 10-20 thousand cycles are so impeded

make your impact on the Int faster.




Other articles:

Aperativchik - On the new shell magazine.

Aperativchik - Joining the authors.

Topic - DIGITAL sound like it is (a player. Wav files).

Topic - Project recovery and development stage.

Topic - The association's AMAZING SOFT MAKING.

Topic - Theory zhurnalostroeniya.

drop of solder - GENERAL SOUND: PLUG & PLAY.

drop of solder - Professional audio processing on a PC.

SOFTWARE - On updates from Samara: MAX SOFT SCREEN PACKER v1.4, Miner, FILE COMMANDER v4.04, SLIDE SHOW, WALKER demo, S-LIGHT BBS, S-TERMINAL v1.0 , LOGO.SYS (for PC).

SOFTWARE - Description prohodilka game "Operation RR"

SOFTWARE - New demoscene: HAPPY NEW 1998 YEAR, BURDENSOME, DREAM, CONDEMED, CONFUSION.

CODING - Procedures: FULL SCREEN SCROLL UP, broken TV.

CODING - Using a stack interrupt enable.

CODING - On the packer MS-PACK.

CODING - Kodit want - Inference Procedure sprites without attributes, quick and versatile procedure for the withdrawal of sprites, the procedure for multiplication and calculate the square root.

ANOTHER WORLD - Multimedia - a synthesis of three elements.

ANOTHER WORLD - AMIGA vs PC.

Hall of Fame - An Interview with PROGRESS.

Hall of Fame - The group ETERNITY INDUSTRY.

Hall of Fame - On the international festival ART COMP-98.

Hall of Fame - determination made in the demoscene and Spectrum.

Hall of Fame - Use the mouse in magazines and other software (for Krivorukov coders).

Hall of Fame - a way to convert tricolor images for Spectrum.

Hall of Fame - Is this the rulez Amiga? HRC for ptsshnikov and Spectrum for spektrumistov?

Seven and 1 / 2 - Army marasmus.

Seven and 1 / 2 - Programming from the bottom up to iskosok.

Seven and 1 / 2 - Safety Instructions for sex.

Seven and 1 / 2 - Features a national ruleza.

Seven and 1 / 2 - Report from the hangouts and Kemerovo spektrumistov sohdateley Journal Deja vu.

attempt at writing - Many Adventures of Winnie the Pooh part 2.

attempt at writing - Fantasy and Science Fiction.

Advertising - Advertisements and announcements ...

News - a new magazine AMIGA RULES.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Humor - anecdotes.
four kilobytes - The new name of the group - Steel Falcons.
HARD - KEMPSTON MOUSE INTERFACE.

В этот день...   21 November