home *** CD-ROM | disk | FTP | other *** search
- {*********************************************************}
- {* DOLINE.INC *}
- {* *}
- {* Integer-DDA als Inline-Code für Z80 Turbo Pascal *}
- {* (C) Heinz Hagemeyer & PASCAL INTERNATIONAL *}
-
- PROCEDURE do_line (x1,y1,x2,y2 : INTEGER);
-
- {Die in der Routine gebrauchten Z80-Codes
- werden hier als Konstanten definiert : }
- CONST inc_bc = $03;
- inc_hl = $23;
- dec_bc = $0B;
-
- BEGIN
- INLINE
- (
- { ;Fuer Normalfall (dx > dy und m > 0) }
- { ;Code's eintragen : }
- $3E/inc_bc/ {ld a,inc_bc ;Code inc bc ( y := y+1 ) }
- $32/*+129/ {ld (incy),a ;und }
- $3E/inc_hl/ {ld a,inc_hl ;Code inc hl ( x := x+1) }
- $32/*+114/ {ld (incx),a ;auf Verdacht eintragen }
- { ;Ist x1 > x2, dann werden die }
- { ;beiden Punkte vertauscht : }
- $ED/$5B/x1/ {ld de,(x1) ;dx := x2 - x1 }
- $2A/x2/ {ld hl,(x2) ;dx < 0 ? }
- $97/ {sub a }
- $ED/$52/ {sbc hl,de }
- $30/$1B/ {jr nc,test_dy ;nein, dann teste dy }
- $19/ {add hl,de ;ja, dann tausche }
- $ED/$53/x2/ {ld (x2),de ;x1 mit x2 }
- $22/x1/ {ld (x1),hl }
- $EB/ {ex de,hl }
- $ED/$52/ {sbc hl,de ;dx := x1 - x2 }
- $ED/$4B/y1/ {ld bc,(y1) ;und tausche }
- $ED/$5B/y2/ {ld de,(y2) ;y1 mit y2 }
- $ED/$53/y1/ {ld (y1),de }
- $ED/$43/y2/ {ld (y2),bc }
- {test_dy: ;dy < 0 ? }
-
- $E5/ {push hl ;dx retten }
- $ED/$5B/y1/ {ld de,(y1) ;dy := y2 - y1 }
- $2A/y2/ {ld hl,(y2) }
- $ED/$52/ {sbc hl,de }
- $30/$09/ {jr nc,dy_g_0 ;Wenn dy > 0 ,
- dann Sprung ( m > 0 !) }
-
- { ;sonst : }
- $19/ {add hl,de ;dy := y1 - y2 }
- $EB/ {ex de,hl }
- $ED/$52/ {sbc hl,de }
- { Code in Routine aendern }
- $3E/dec_bc/ {ld a,dec_bc ;dec bc (= y-1) }
- $32/*+64/ {ld (incy),a ;eintragen }
-
- {dy_g_0 }
-
- $D1/ {pop de ;de := dx }
- $D5/ {push de ;dx retten }
- $E5/ {push ;dy retten }
- $ED/$52/ {sbc hl,d ;hl := dy - dx }
- $38/$0F/ {jr c,weiter ;Wenn dx>dy, dann Sprung }
-
- { ;sonst }
- $D1/ {pop de ;de := dy | tausche }
- $E1/ {pop hl ;hl := dx | dx mit dy }
- $D5/ {push de ;dy retten | auf dem }
- $E5/ {push hl ;dx retten | Stapel }
-
- { und aendere Code's entsprechend }
-
- $3A/*+50/ {ld a,(incy) ;Code y+1 (oder y-1) }
- $32/*+37/ {ld (incx),a ; statt x+1 und }
- $3E/inc_hl/ {ld a,inc_hl ;Code x+1 statt y+1 }
- $32/*+42/ {ld (incy),a ;(oder y-1) in eintragen }
-
- { weiter }
-
- {**************************************************** }
- {* 2. Registersatz 1. Registersatz * }
- {* * }
- {* BC = DX (DY) HL = X * }
- {* DE = DY (DX) BC = Y * }
- {* HL = DSUM DE = Steps * }
- {**************************************************** }
-
- $D1/ {pop de ;de := dy (dx) }
- $C1/ {pop bc ;bc := dx (dy) }
- $C5/ {push bc ;rette steps
- ;(wegen 1. Registersatz!)}
- $60/ {ld h,b ;hl := dsum = dx/2 }
- $69/ {ld l,c }
- $CB/$3C/ {srl h }
- $CB/$1D/ {rr l }
- $D9/ {exx ;1. Registersatz ! }
- $2A/x1/ {ld hl,(x1) }
- $ED/$4B/y1/ {ld bc,(y1) }
- $D1/ {pop de ;steps holen }
- $CD/STATUS/ {call status ;siehe Begleittext }
- { repeat ;Punkt ausgeben }
-
- $D5/ {push de ;steps retten }
- $C5/ {push bc ;y retten }
- $E5/ {push hl ;x retten }
- $CD/PUNKT+16/ {call punkt + 16;BC = Y HL = X
- ; (Vergl. Begleittext) }
- $E1/ {pop hl ;x holen }
- $C1/ {pop bc ;y holen }
- $D1/ {pop de ;steps holen }
-
- {incx: ;Im Normalfall x := x+1 }
-
- $23/ {inc hl ;hier wird Code
- ;eingetragen }
- $D9/ {exx ;2 Registersatz }
- $19/ {add hl,de ;dsum := dsum + dy }
- $ED/$42/ {sbc hl,bc ;dsum >= dx ? }
- $38/$05/ {jr c,step ;nein, nur step in x }
- $ED/$42/ {sbc hl,bc ;ja, dsum := dsum - dx }
- $D9/ {exx ;1. Registersatz }
-
- {incy: ;im Normalfall y := y+1 }
-
- $03/ {inc bc ;hier wird Code
- ;eingetragen }
- $D9/ {exx ;2. Registersatz }
-
- {step: }
-
- $09/ {add hl,bc ;Korrektur w. sbc hl,bc }
- $D9/ {exx ;1. Registersatz }
- $1B/ {dec de ;steps := steps - 1 }
- $CB/$7A/ {bit 7,d ;etwa negativ ? }
- $28/$E4); {jr z,repeat ;nein, dann noch'n Punkt }
- { ;sonst fertig }
-
- END { do_line };
-