home *** CD-ROM | disk | FTP | other *** search
-
- ;---------------
- ;-- Sortering --
- ;---------------
-
-
- AntVarden: = 80
-
- S: lea.l $dff000,a6
- move.w $1c(a6),d0
- bset #15,d0
- move.w d0,OldIrq
- move.w #$4000,$9a(a6)
- bsr Slumpa
- bsr MainLoop
- move.w OldIrq(pc),$9a(a6)
- moveq #0,d0
- rts
-
- OldIrq: dc.w 0
-
- Slumpa: lea.l Posses(pc),a0
- move.w #8392,d1
- move.w #14,d2
- move.w #2,d3
- move.w #AntVarden-1,d7
- SlumpLoop: move.w $6(a6),d0
- muls d2,d1
- add.w d3,d2
- and.w #$ff,d0
- move.w d0,(a0)+
- dbra d7,SlumpLoop
- rts
-
- MainLoop: cmp.b #$50,$6(a6)
- bne.S MainLoop
- move.w #$f00,$180(a6)
- bsr Sortera
- move.w #$a,$180(a6)
- btst #6,$bfe001
- bne.S MainLoop
- rts
-
- Sortera: lea.l Posses(pc),a0
- lea.l Posses2(pc),a1
- move.w #AntVarden-1,d7
- SL: move.w (a0)+,(a1)+
- dbra d7,SL
-
- lea.l Posses2(pc),a0
- lea.l Sorterade(pc),a1
- moveq #0,d6
- moveq #0,d2
- move.w #AntVarden-1,d7
- SortLoop: move.w (a0)+,d0
- move.w d6,d5
- lsr.w #1,d5
- move.l a1,a2
- cmp.w d0,d2
- bhi.S NoLow
- move.w d0,(a1,d6.W)
- addq.w #2,d6
- move.w d0,d2
- bra.S Next
- NoLow: cmp.w (a2)+,d0
- bls.S NoLika
- dbra d5,NoLow
- NoLika: add.w d5,a2
- add.w d5,a2
- move.l a2,a3
- subq.l #2,a2
- MoveLoop: move.w -(a2),-(a3)
- dbra d5,MoveLoop
- move.w d0,2(a2)
- addq.w #2,d6
- Next: dbra d7,SortLoop
- rts
-
- Posses: blk.w AntVarden,0
- Posses2: blk.w AntVarden,0
- Sorterade: blk.w AntVarden,0
-
-