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
- move.l a0,a1
- move.w #AntVarden-1,d0
- add.w d0,d0
- add.w d0,a1
- move.l a0,a2
- move.l a1,a3
- move.w #AntVarden,d7
- move.w d7,d5
- lsr.w #1,d7
- subq.w #1,d7
- SortLoop: move.w d5,d6
- SortLoop2: move.l a2,a0
- move.l a3,a1
- move.w (a0)+,d0
- Search: cmp.w (a0)+,d0
- bhi.S NoChange
- lea.l -2(a0),a4
- NoChange: dbra d6,Search
- move.w d5,d6
- Search2: cmp.w -(a1),d0
- bls.S NoChange2
- lea.l -2(a0),a5
- NoChange2: dbra d6,Search2
- move.w (a4),d2
- move.w (a5),(a4)
- move.w d2,(a5)
- addq.l #2,a2
- subq.l #2,a3
- subq.w #2,d5
- dbra d7,SortLoop
- rts
-
- Posses: blk.w AntVarden,0
- Posses2: blk.w AntVarden,0
- Sorterade: blk.w AntVarden,0
-
-