Aspect #07
07 марта 1998

Programming - Arrow.

<b>Programming</b> - Arrow.
       Arrow WITHOUT Switchman ...

 Probably many, running X-REVERSY, or
FONT EDITOR, or the same ASPECT seen
the tool control of programming
product. And, certainly, attempts Scodie
arrow did not lead to desirable: for
move the arrow blinking, twitching, and
when trying to make her own, but through
interruption, the image is likely to
disappeared altogether.
 I also had similar problems, but their
been overcome. First, we must
get rid of heaps of teams RRCA / RLCA, and
is very simple: instead of
moving image direction during
O, it is necessary to move him before the withdrawal, and
polozht in memory (of 8 images)
and no need to calculate the address output
screen with 8,880 procedures or her
like - fill in the table ...
And here is the code:


   ORG 30000

   CALL ZAPTAB; fill in the address table

   CALL ZAPSTR; do 8 images

            The arrows and masks for

            The arrows

   CALL OUTMAR; derive arrow

   LD HL, INTERR; put his handler

            ; Interrupt

   CALL IMON
MMMM EI; forward

   HALT

   LD A, (HOLDING +1); until you

   AND A; FIRE button on KEMPSTONe or

   JR NZ, MMMM; SINCLAIRe or SPACE for

   RET; clave, oposlya then leave ...

, Procedure interrupt

INTERR DI; to any fireman

   PUSH HL; ethno must be preserved ...

   PUSH DE

   PUSH BC

   PUSH AF

   EXX

   PUSH HL

   PUSH BC

   PUSH DE

   EX AF, AF '

   PUSH AF

   PUSH IX

   PUSH IY; ... on memory
HOLDING LD A, 2, and whether it is necessary that the thread

   AND A; displayed on the screen?

   JR Z, UPR; no!

   CALL ZATIR; overwrites the image arrow

   DEC A; overwrite and no longer walk?

   JP Z, FIRE1; yes!

   XOR A; will drop box pressing

   LD (FLG), A

   CALL KBDJOY; check management

   RRCA; if you need to move the arrow

   PUSH AF

   CALL C, RIGHT

   POP AF

   RRCA

   PUSH AF

   CALL C, LEFT

   POP AF

   RRCA

   PUSH AF

   CALL C, DOWN

   POP AF

   RRCA

   PUSH AF

   CALL C, UP

   POP AF

   RRCA

   JR C, FIRE; flame - lit it go ..

   LD A, (FLG); button is not pressed?

   AND A

   JR NZ, UPR1; sad but true

   INC A; if pitch is equal to one

   LD (RAZ), A
UPR1 CALL OUTMAR; derive arrow
UPR POP IY; restore everything

   POP IX

   POP AF

   EX AF, AF '

   POP DE

   POP BC

   POP HL

   EXX

   POP AF

   POP BC

   POP DE

   POP HL

   EI

   RET; and go myself ...

; Light pressed, however,

FIRE LD A, 1; Hard to image and
FIRE1 LD (HOLDING +1), A; go to

   JP UPR; idle

; Move right

RIGHT LD A, (POSX); coordinate of X

   LD C, A

   LD A, (RAZ); step arrows

   ADD A, C

   RET C; the screen (255 + n = n-1 CY = 1)

   LD (POSX), A
MET LD A, 1 click!

   LD (FLG), A

   LD A, (RAZ); can not go faster?

   CP 1913

   RET NC; impossible!

   INC A; accelerates

   LD (RAZ), A

   RET

; Move to the left

LEFT LD A, (POSX)

   LD BC, (RAZ)

   CP C; coordinate smaller steps?

   RET C; hence can not be left

   SUB C; move to the left

   LD (POSX), A

   JP MET

; Go up

UP LD A, (POSY)

   LD BC, (RAZ)

   CP C; above Y = 0 only ROM

   RET C

   SUB C

   LD (POSY), A

   JP MET

; Move down

DOWN LD A, (POSY)

   LD BC, (RAZ)

   ADD A, C

   CP 191; Below Y = 191 we do not need

   RET NC

   LD (POSY), A

   JP MET

; Installation procedure interrupt
; The entrance - HL address of the procedure
; Interrupt
; Spoils: HL, BC, DE, AF

IMON

   DI

   LD A, 24

   LD (65535), A

   LD A, 195

   LD (65524), A

   LD (65525), HL

   LD HL, # FE00

   LD DE, # FE01

   LD BC, 256

   LD A, H

   LD (HL), # FF

   LDIR

   DI

   LD I, A

   IM 2

   EI

   RET

; Output arrows
; With addresses TABLE should be a table
; Address output
; To address BUFFER must be empty
; Space of not less than 32 bytes
; To address STR0 have found data
, For the arrow that is 8 sprites arrows
, And a mask and in this form:
; Byte mask byte arrows
The length of the arrows 2 bytes (the length of the mask
, Also 2 bytes), height 16 pixels
, Ie with STR0 must be 512 bytes.

OUTMAR LD BC, (POSX); take the position output

   LD (ZTPOSX), BC; put it in a procedure

            ; Mashing

   LD E, B

   LD D, 0

   LD IX, TABLE; find the starting address

   ADD IX, DE; output in the table

   ADD IX, DE

   LD (ZATIR +2), IX; put it in the procedure

   LD IY, BUFFER; mashing, in IY - buffer

            , Which will be kept of

            ; Screen hit by an arrow

   LD A, C; calculate the sprite to display

   AND 7

   LD B, A
OUTMX LD HL, STR0

   AND A

   JR Z, OUTM2

   LD DE, 64
OUTM1 ADD HL, DE

   DJNZ OUTM1
OUTM2 LD B, # 10

   SRL C; in C - Column

   SRL C

   SRL C

   LD A, C

   INC A

   AND # 1F; at the end of the screen

   JR Z, OUTM7; yes!
OUTM4 EX DE, HL

   LD A, (IX)

   CP # FF; below the screen - does not derive

   RET Z; ...

   ADD A, C; address display

   LD L, A

   LD H, (IX +1)

   INC IX

   INC IX

   PUSH BC

   EX DE, HL

   LD B, (HL); take the mask

   INC HL

   LD C, (HL); take the data

   INC HL

   LD A, (DE)

   LD (IY), A

   INC IY

   AND B; impose

   OR C

   LD (DE), A; deduce

   INC DE

   LD A, (DE)

   LD (IY), A

   LD B, (HL)

   INC HL

   LD C, (HL)

   AND B

   OR C

   LD (DE), A

   INC IY
OUTM6 INC HL

   POP BC

   DJNZ OUTM4

   RET
OUTM7 EX DE, HL; the same thing, only

   LD A, (IX); displayed one byte instead of

   CP # FF; two

   RET Z

   ADD A, C

   LD L, A

   LD H, (IX +1)

   INC IX

   INC IX

   PUSH BC

   EX DE, HL

   LD B, (HL)

   INC HL

   LD C, (HL)

   INC HL

   INC HL

   INC HL

   LD A, (DE)

   LD (IY), A

   INC IY

   AND B

   OR C

   LD (DE), A

   POP BC

   DJNZ OUTM7

   RET

; Procedure, the reconstructed image
; The arrow

ZATIR LD IX, # 4000; there will be another

   LD HL, BUFFER

   LD B, # 10

   LD A, (ZTPOSX)

   SRL A

   SRL A

   SRL A

   LD C, A

   LD A, C

   INC A

   AND # 1F

   JR Z, ZATIR3
ZATIR1 LD A, (IX)

   CP # FF

   RET Z

   ADD A, C

   LD E, A

   LD D, (IX +1)

   LDI

   LDI

   INC BC

   INC BC

   INC IX

   INC IX

   DJNZ ZATIR1

   RET
ZATIR3 LD A, (IX)

   CP # FF

   RET Z

   ADD A, C

   LD E, A

   LD D, (IX +1)

   LDI

   INC BC

   INC IX

   INC IX

   DJNZ ZATIR3

   RET

; Response to the buttons and joystick

KBDJOY IN A, (31); Kempston with us?

   LD E, A

   AND 3

   CP 3

   JR NZ, KBDJ1; yes!

   LD E, 0, no, walk out
KBDJ1 LD HL, DKEY; data about the keys

            ; Management
KBDJ2 LD C, (HL); take the port address

   INC C

   DEC C

   LD A, E

   RET Z; if 0 then this is the end ...

   INC HL

   LD B, (HL)

   INC HL

   IN A, (C); read data from the porch

   CPL

   AND (HL); select the desired bit

   INC HL

   JR Z, KBDJ3; such we have not clicked

   LD A, (HL); clicked, take The figures in

   OR E

   LD E, A
KBDJ3 INC HL

   JR KBDJ2

; Procedure produced eight sprites to
; Arrows on STR0 should be
; Sprite in the above format

ZAPSTR LD IX, STR0
ZAPSTRX PUSH IX

   LD HL, STR0

   LD DE, 64

   LD C, 8

   ADD HL, DE

   PUSH HL

   POP IY
ZAPST2 POP IX

   PUSH IY

   LD B, # 10
ZAPST1 CALL ZAPBYT

   INC IX

   INC IY

   LD A, (IX)

   AND A

   CALL ZAPBY1

   INC IX

   INC IX

   INC IX

   INC IY

   INC IY

   INC IY

   DJNZ ZAPST1

   DEC C

   JR NZ, ZAPST2

   POP IX

   RET
ZAPBYT LD A, (IX)

   SCF
ZAPBY1 RRA

   LD (IY), A

   LD A, (IX +2)

   RRA

   LD (IY +2), A

   RET

; Fills the address table with addresses
; TABLE

ZAPTAB LD IX, TABLE

   LD HL, # 4000

   CALL ZAPADR

   LD HL, # 4800

   CALL ZAPADR

   LD HL, # 5000

   CALL ZAPADR

   LD (IX), # FF

   LD (IX +1), # FF

   LD (IX +2), # FF

   RET
ZAPADR LD DE, # 20

   LD C, 8
ZAPAD2 PUSH HL

   LD B, 8
ZAPAD1 LD (IX), L

   LD (IX +1), H

   INC IX

   INC IX

   INC H

   DJNZ ZAPAD1

   POP HL

   ADD HL, DE

   DEC C

   JR NZ, ZAPAD2

   RET

; Data for the survey of the keyboard:
; Ml.bayt port, the port st.bayt, mask, weight

DKEY DEFB # FE, # FB, 1,8, # FE, # FD, 1,4, # FE, # DF

   DEFB 2,2

   DEFB # FE, # DF, 1,1, # FE, # 7F, 1,16


   DEFB # FE, # EF, 16,2, # FE, # EF, 8,1, # FE, # EF, 4,4

   DEFB # FE, # EF, 2,8, # FE, # EF, 1,16


   DEFB 0

; Buffer for a piece of the screen

BUFFER DEFS 32

; Data for the arrows

STR0 DEFB 159,0,255,0,135,32,255,0,131,48

   DEFB 255,0

   DEFB 129,56,255,0,128,60,255,0,128,62,255

   DEFB 0

   DEFB 128,63,255,0,128,56,255,0,193,36,255

   DEFB 0

   DEFB 240,4,255,0,248,2,255,0,252,2,255,0

   DEFB 252,0,255,0,255,0,255,0,255,0,255,0

   DEFB 255,0,255,0

   DEFS 480

; Variables arrows

ZTPOSX DEFB 0
ZTPOSY DEFB 0
FLG DEFB 0
RAZ DEFB 1
POSX DEFB 32
POSY DEFB 32

, Address table

TABLE

Now why I have a procedure
O arrow actually consists of two
procedures: the fact that faster
check once at the beginning, rather than 16-fold
during withdrawal. Incidentally, the fact that
the above example, the arrow was
implemented via interrupts is not
means that this is the way it should be: do
arrow through the interrupt sense
when displayed on the screen
dynamic image (such as labels
ASPECT). Well, so far, and all soon!


                          (C) Trusov Ilya







Other articles:

BBS-List - List Vicomm-compatible BBS.

Up Work Sorpa - The indicator for signaling the driver drive. Toggle switch to switch drives.

Contest - Competition for the best poster / logo for FunTop'98.

Let's start with the basics - Electrical network and Ohm's law.

New - of updates: the game Margo.

News - Closing the Gate SPbZXNet <=> Internet. The new dial-up newspaper SPbZXWeek.

From the authors - A whole month no hearing, nor spirit ...

Festival - In the spring you people!

Pro Life - The computer - a good man ...

Programming - Arrow.

Hit Parade - 10-ka best games.

Humor - The distribution of malicious programs.


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

Similar articles:
From the Author - Day of humor.
Miscellaneous - Electronic Samizdat: A few words about a new kind of software - Electronic books.
HOT GAMES - Top Ten by Magic Soft.

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