home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Oakland CPM Archive
/
oakcpm.iso
/
cpmug
/
cpmug035.ark
/
POSIT.ASM
< prev
next >
Wrap
Assembly Source File
|
1984-04-29
|
3KB
|
118 lines
; 23 MAR:PUT WITTENBERG'S 'FLY' ALGORITHM INTO POSIT.
* POSIT * TYE SHULTZ / 3 FEB 79 / VERSION 1.2
*
* 'POSIT' TRANSLATES THE OBJECT NAMEDD BY THE FIRST PARAMETER SO THAT
* ITS CENTER-OF-GRAVITY (BYTES 2,3) IS AT SCREEN LOCATION
* INDICATED BY THE NEXT TWO PARAMETERS.
*
* --IF CALLED AT 'POSCALL',RELOCATES OBJECT NAMED IN REG.D
* TO POSITION B,C.
*
* SYSTEM SUBROUTINES: INPARM, OBJR, OBJW
*
* ALL REGISTERS ARE RESTORED ON EXIT.
*
PIXEL1X EQU 2
INPARM EQU 5030H
OBJR EQU 5006H
OBJW EQU 5009H
SPECODE EQU 0FFH
ENDFLAG EQU 80H
ORG 2DB0H
*
*
; GET OBJECT NUMBER, AND DESIRED X,Y OF FIRST PIXEL.
;
CALL INPARM ; SAVE OBJ # IN D.
MOV D,E
XCHG ; SAVE OBJ # TEMPORARILY IN H.
CALL INPARM ; SAVE NEW X IN B.
MOV B,E
CALL INPARM ; SAVE NEX Y IN C.
MOV C,E
XCHG ; GET OBJ # BACK IN D.
;
; FIGURE DISPLACEMENT FROM OLD FIRST X TO NEW ONE.
;
MVI E,PIXEL1X ; SELECT BYTE 2 (X OF CTR OF GRAV).
CALL OBJR ; GET FIRST X INTO 'A'.
SUB B ; SUBTRACT NEW FIRST X FROM IT.
CMA
INR A ; COMPLEMENT DISPLACEMENT.
MOV H,A ; SAVE DISPLACEMENT FOR TRANSLATION LOOP.
MOV A,B ; SAVE NEW FIRST X IN OBJECT.
CALL OBJW
MOV B,H ; SET UP TRANSLATION VECTOR X.
;
; FIGURE DISPLACEMENT FROM OLD FIRST Y TO NEW ONE.
;
INR E ; POINT E AT BYTE 6. (OLD FIRST Y COORD.)
CALL OBJR ; 'A' NOW HAS THE OLD Y.
SUB C ; SUBTRACT NEW Y FROM OLD.
CMA ; NEGATE DISPLACEMENT.
INR A ;
MOV L,A ; SAVE DISPLACEMMENT FOR TRANSLATION LOOP.
MOV A,C ; SET NEW FIRST PIXEL Y IN OBJECCT.
CALL OBJW
MOV C,L ; SET UPP TRANSLATION VECTOR Y.
;
;
; -IF YOU ENTER TRANSLATE LOOP FROM ABOVE(POSIT) THEN
; E=4 HERE, BECAUSE CTR OF GRAV.ALREADY FIXED.
;
; SET UP FOR TRANSLATE LOOP.
;
FLYIN: MVI H,SPECODE ; SET H TO SPECIAL CODE.
MVI L,ENDFLAG ;L CONTAINS END-OF-OBJ.FLAG.
;
; TRANSLATE LOOP...................................
TRANS: MOV A,B
ORA A
JP FLNEXT
DCR B ;THIS MAKES A '-1' BE 'FE'
FLNEXT: INR E ;NEXT OBJ'S X-BYTE.
CALL OBJR
CMP H ;IS IT SPECIAL CODE?
JNZ FLADD ;NO,SO GO DEAL WITH IT.
;YES,SPEC.CODE.IS IT SPEC.CODE 80(END OF OBJ?)
INR E
CALL OBJR
CMP L ;WHICH HOLDS 80
JNZ FLNEXT
RET ;ALL OVER.
;
FLADD: ADD B ;ADD X-CHANGE TO X VALUE.
JNC NOINRA ;IF THERE WAS A CARRY WE MUST
INR A ;'BUMP' RESULT.WE EFFECTIVELY
NOINRA: CMP H ;DO 1'S COMPLEMENT ARITH.
JNZ NOIN
INR A ;THIS PUSHES FF UP TO 00.
NOIN: CALL OBJW ;PUT 'FLOWN' X OUT.
INR E
CALL OBJR
ADD C ;WE FLY Y NOW.
CALL OBJW
JMP FLNEXT
;
; FLY --- JMM 3/79
; -ALGORITHM FROM WITTENBERG,AU 78.
;
;FLY TAKES 3 PARAMS: OBJECT, X-CHANGE, Y-CHANGE.IT MOVES
;THE OBJECT BY THAT DIS. ON EVERY CALL. SHARES CODE WITH
; 'POSIT'.
; FLY CAN BE CALLED A FLYCALL. OBJECT D IS FLOWN BY
; DISTANCE (B,C ).
;
ORG 2E30H
FLY: CALL INPARM
MOV H,E
CALL INPARM
MOV B,E ;DELTA-X IN B
CALL INPARM
MOV C,E ;DELTA-Y IN C
MOV D,H
FLYCALL:MVI E,1 ;POINTER IN OBJR CALLS (COMING UP)
JMP FLYIN
;
END