░░░ ░░░ ░▒▒▒░ ░░░ ░░░ ░▒░░ ░░░░░ ░░░ ░░░ ░▒░ ░░░░░░
░█▓░ ▓█▒ ░▓████░ ▒█▓ ██░ ░███▓ ░████▓ ▓█▒ ░██░ ▒███▒ ░████▒
░██▒ ▓█▓ ▓██████░ ▒██░ ██▒ ▒████░░████▓ ▓█▓░░██░ ▓███▓ ▒████▒
░██▓░▓██░░██▓▒▓██▒ ▒██▒ ██▓ ▓█▓█▒ ▒████▒ ▓██░░██▒ ██▓█░ ▓████░
░███░▓█▒ ▒██░ ░▓█▓ ▒███░██░ ▓█▒░ ██░ ▓██▓░██ ██░░ ░██
░███▓▓█▒ ▒█▓ ▒█▓ ▒███▒██░ ▒██░ ██▓▓▒ ▓███▒██ ▓█▓░ ░██▓▓░
░██████▒ ▒█▓░ ▒█▓ ▒██████░ ▒██░ ████▒ ▓██████ ░▓█▓░ ░████░
░██▓███▒ ▒██▒ ▓█▓ ▒█▓████░ ░██░ ██▓▓░ ▓█▓████ ▒█▓░░██▓▓░
░██░███▒ ░███▒▒██▒ ▒█▓▒███░ ░▒░██▓ ██░ ▓█▒▓███ ░░░██▒░██
▓██ ▓██▒ ░▓██████░░██▓░▓██░░▓████▒ █████ ░██▒░███ ░█████░░████▓
▒██ ░██▒ ░▓████░ ▓█▓ ▒██░░▓████░ ████▓ ░██▒ ▓██ ░████▓░░████▒
░▒▒ ▒▒░ ░▒▒▒░ ░▒▒ ░▒▒░ ░▒▒▒░ ▒▒▒▒▒ ▒▒░ ░▒▒ ░▒▒▒░ ░▒▒▒▒░
in basic...
(c) Pix/BrC Ижевск
──────────────────────────────────────────
┌─┐
│
└─┘ вами в очередной раз main coder of
Brutal Creators (да простит меня Noviset).
Сегодня я буду глючить на тему построения
курсора. Я, конечно, не спец в этой облас-
ти, и если вам нужен клёвый и быстрый кур-
сор, то это вам читать противопоказано.
Если же вам побоку крутость, то читаем
далее.
Вот,now only those who don't remain
found articles about the cursor, or those who
is guided by the principle “as long as it sings”, and
also those who are not very good at codes and
wants to understand how it fucking works -
et. It is for the latter that this article was written.
I'll start with the problems that arise among the most
Beginer coders. Often the first own
the hand-written cursor disappears into
the top of the screen or begins to flicker.
I will try to explain the reason for what is happening.
To do this, consider the construction principle
images on the monitor screen. As I know
Seriously, this wonderful event is happening
50 times per second, immediately after arrival
interruptions. The cursor is usually built in pro-
interrupt handling procedure, i.e. cursor and
the images are constructed simultaneously. In pro-
The processing procedure takes place approximately
the following:
a) restore the image under the
with the right cursor (erase it);
b) save the image in a new position
tions;
c) build a new cursor;
That. we must complete all 3 points before
from the moment the video controller builds
image above the position of the cursors(old-
th and new). Usually a braking procedure
does not have time to draw a new cursor before
the moment when its location
starts to appear on the monitor, so we
We don’t even see him. Hence the rule: you need to
build a new cursor while the bor-
der, and this requires relatively fast
ryprocedures. .
Well, let's say:
BEGXP EQU 184 ;initial coordinates
BEGYP EQU 0 ;у=184 x=0
XY_KOOR DB BEGXP,BEGYP ;current coordinates.
Our procedures must be fast,
therefore, all complex (braking) calculations
Let's do it once. For example, printing with
that with pixel accuracy is only possible by
y-ku,and by x discrete step (8pix). But we
you need to print both y andxwith one
with a precision equal to 1 pixel. For this -
you need to move the sprite by a number of pixels
equal to the remainder of division by 8. i.e. if
х=10, then p=x%8=2, means you need to move
sprite 2 pixels to the right, and then print-
put it in position x/8(char), y(pixel).
This can be done during the printing process, but this
it will be slow, so we’ll do it to our
the original sprite has 7 more formed from non-
th by shift. These are the ones we will use.
call during the withdrawal process. All this muta-
new will handle the initialization procedure -
tions:
INIT_CUR ;the actual procedure for initializing the cursor.
LD A,BEGXP
LD(XY_KOOR),A
LD A,BEGYP
LD(XY_KOOR+1),A
Let's create a screen address table for
printing system according to Y. To do this, let’s go through everything
lines from0 to 192and write their addresses to
started in Tabl_adr.
INT_TAB LD DE,#4000 ;beginning of the screen area
LD HL,TABL_ADR ; HL = table address
LD B,192 ; number of lines
INT_TB1 LD (HL),D ; enter the address of the line that
INC HL ; is in DE.
LD (HL),E ; ..
INC HL ; ..
CALL DOWN_DE ; Calculate the address of the next line
DJNZ INT_TB1 ; Let's go through all the lines.
Now let's create the sprites we're talking about
rushed higher. At the same time mix it with
mask.
LD HL,SUR_CUR ; original sprite
LD DE,CURSPR ; That's where we'll shift it.
LD BC,32 ; length of one sprite with mask
LDIR ; first - offset #00
INT_SPR LD B,8 ; like the number of new sprits.
LD DE,NEW_SPR ; new sprite written.
INT_SPO PUSH BC ; for the cycle :)
LD HL,CURSPR ; start of the sprit
LD IX,CURSPR+16 ; beginning of the mask
LD B,16 ; sprite length or masks
INT_SP1 LD A,(IX) ; we take a mask
LD (DE),A ; we put where we need to
INC DE ; after. elem
LD A,(HL) ; we pick up sprit
LD (DE),A ; calm down
INC DE ; after.
INC HL ; after. ref.
INC IX ; nail mask
DJNZ INT_SP1 ; well, cycle, kind of.
Vot, mixed mask with sprite, now
we have a sprite with mask in mask format,
sprite, mask, sprite...with offset #00.Te-
let's move.
LD HL,CURSPR ; outcome for displacements.
LD B,8 ; height, born
INT_SP2 LDA,(HL) ; берем
OR A ; cy=0
RRA ; ->
LD (HL),A ; ложим на место
INC HL ; след.
LD A,(HL) ; берем 2-ой байт сприта
RRA ; ->
LD (HL),A ; кладем
INC HL ; далее
DJNZ INT_SP2 ; ну и так далее...
LD HL,CURMASK ;
LD B,8 ;
INT_SPЗ LD A,(HL) ; Тожа самое для маски
SCF ; cy=1
RRA ; ->
LD (HL),A ;
INC HL ;
LD A,(HL) ;
RRA ;
LD (HL),A ;
INC HL ;
DJNZ INT_SPЗ ; с масками все...
POP BC ;
DJNZ INT_SPO ; след. смещение, след. сприт
LD A,#37 ;
LD (CUR_PR),A ; кое-какие предустановки
JP PR_CUR_ ; ну и все,инсталл закончен, появ-
; ляем первый куроср.
DOWN_DE INC D ; проца вычисления адреса след строки
LD A,D; from the previous address. Standard.
AND 7
RET NZ
LD A,E
ADD A,#20
LD E,A
RET C
LD A,D
SUB 8
LD D,A
RET
Now the procedures for printing the cursor. Here,
it seems that everything is simple: a little mathematics, obviously
not a little. No stack output.
Speed is achieved without shear
sprites. Here are the steps to restore the
under the old cursor. I think you'll figure it out
Try it yourself, I'm already lazy... :)
PR_CUR LD A,0
LD B,0
LD C,A
SLA C
RL B
LD HL,TABL_ADR
ADD HL,BC
LD D,(HL)
INC HL
LD E,(HL)
PR_CURO LD A,0
SRL A
SRL A
SRL A
ADD A,E
LD E,A
JR NC,PRCO
INC D
PRCO LD HL,SPR_BUF
LD B,8
PRC__LD A,(HL)
INC HL
LD(DE),A
INC DE
LD A,(HL)
LD(DE),A
DEC DE
INC HL
CALL DOWN_DE
DJNZ PRC__
WOST_PR OR A
RET C
PR_CUR_LD A,(XY_KOOR)
LD(PR_CUR+1),A
LD B,0
LD C,A
SLAC
RL B
LD HL,TABL_ADR
ADD HL,BC
LD D,(HL)
INC HL
LD E,(HL)
LD A,(XY_KOOR+1)
LD (PR_CURO+1),A
SRL A
SRL A
SRL A
ADD A,E
LD E,A
JR NC,PRCO
INC D
PRCO LD A,(XY_KOOR+1)
AND 7
LD BC,NEW_SPR
LD H,0
LD L,A
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,HL
ADD HL,BC
LD IX,SPR_BUF
LD B,8
PRC1 LD A,(DE)
LD (IX),A
INC IX
AND (HL);MASK
INC HL
XOR (HL);CUR
INC HL
LD (DE),A
INC DE
LD A,(DE)
LD (IX),A
INC IX
AND (HL);MASK
INC HL
OR (HL);CUR
INC HL
LD (DE),A
DEC DE
CALL DOWN_DE
DJNZ PRC1
RET
Ну и загрузим спритик курсора и маски.
SUR_CUR LCODE "CurSpr22.C";fixed line noatr (smS.11)
Что!? Давненько не видели столь убогого
коду? Погодите, еще не такое напишу! Ведь
никто не против? Ну, ладно, все, пухните и
пишитеwhat the hell, can you write some articles?
to nonsense, otherwise you will only read mine
nonsense.
────────────── ────────────────────────────
Share your thoughts about the article