home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ; :Program. LoadBody.asm
- ; :Author. Fridtjof Siebert
- ; :Address. Nobileweg 67, D-7-Stgt-40
- ; :Phone. 0711/822509
- ; :Shortcut. [fbs]
- ; :Version. .01
- ; :Date. 06-Jun-88
- ; :Copyright. PD
- ; :Language. 68000-Assembler
- ; :Translator. Profimat.
- ; :Imports. none.
- ; :UpDate. none.
- ; :Contents. Prozedur zum Laden des BODYs eines gepackten ILBM-Bildes.
- ; :Remark. There is some MODULA on the right to improve clearity.
- ;----------------------------------------------------------------------------
- ;
- ; PROCEDURE LoadBody(GetData: PROC; Buffer,BitMapPtrs: ADDRESS; LineLength,
- ; LineWidth: LONGINT; Height,Depth: INTEGER;
- ; ExtraPlane: BOOLEAN);
- ;
- ;
- ;------ Exported Procedure: ------
- ;
- XDEF LoadBody
- ;
- ;------ Values from caller: ------
- ;
- GetData equr A2;
- Buffer equr A3;
- BitMapPtrs equr A4;
- LineLength equr D2;
- LineWidth equr D3;
- Height equr D5;
- Depth equr D4;
- ExtraPlane equr D6;
- ;
- ;------ Variables: ------
- ;
- Line equr D5;
- Plane equr D6;
- Byte equr D7;
- Location equr A1;
- Right equr A6;
- ;
- Scratch equr D0;
- count equr D1;
-
- Extra = 0;
- AnzLines = 2;
- ;
- ;----------------------------------------------------------------------------
-
- LoadBody:
-
- ;
- ;------ Save some data (there aren't enough Registers): ------
- ;
- subq #4,A7
- move.w ExtraPlane,Extra(A7);
- move.w Height,AnzLines(A7);
- ;
- ;------ Get Data from File (512 Bytes): ------
- ;
- movem.l D2-D7/A1-A6,-(sp);
- jsr (GetData); GetData();
- movem.l (sp)+,D2-D7/A1-A6;
- move #0,count; count := 0;
- ;
- ;------ Initialize Loop for Lines: ------
- ;
- move #0,Line; Line := 0;
- ;
- LineLoop: ; REPEAT
- ;
- ;------- Initialize Loop for Planes: ------
- ;
- move #0,Plane; Plane := 0;
- ;
- PlaneLoop: ; REPEAT
- ;
- ;------ Calculate Position within Image: ------
- ;
- move LineWidth,Scratch;
- mulu Line,Scratch;
- move.l Scratch,Location;
- asl #2,Plane;
- add.l 0(BitMapPtrs,Plane),Location; Location := BitMapPtrs^[Plane];
- asr #2,Plane;
- ;
- ;------ Calculate Position after the Plane-Loop: ------
- ;
- move.l Location,Right;
- add.l LineLength,Right; Right := Location + LineLength;
- ;
- ;------ Let's read the data: ------
- ;
- ReadRepeat: ; REPEAT
- ;
- ;------ Get 1 Byte and check it: ------
- ;
- bsr GetByte; Scratch := GetByte();
- cmp.b #128,Scratch;
- bhi.s RepeatNext;
- beq.s DoRien; IF Scratch<128 THEN
- ;
- ;------ Get Next Scratch+1 Bytes Liberately: ------
- ;
- move.b Scratch,Byte; Byte := Scratch;
- GetMany: ; REPEAT
- bsr GetByte; Scratch := GetByte();
- move.b Scratch,(Location); Location^ := Scratch;
- addq.l #1,Location; INC(Location)
- subq.b #1,Byte; DEC(Byte);
- bpl.s GetMany; UNTIL Byte<0;
- bra.s DoRien;
- ;
- ;------ Get Next Byte and Repeat it 257-Scratch times: ------
- ;
- RepeatNext: ; ELSIF Scratch>128 THEN
- move.b Scratch,Byte; Byte := Scratch;
- bsr GetByte; Scratch := GetByte();
- RepeatIt: ; REPEAT;
- move.b Scratch,(Location); Location^ := Scratch;
- addq.l #1,Location; INC(Location);
- addq.b #1,Byte; INC(Byte);
- cmp.b #1,Byte; UNTIL Byte=1;
- bne.s RepeatIt; END;
- ;
- ;------ Compare new Location with first of next Line: ------
- ;
- DoRien:
- cmp.l Location,Right; UNTIL Location>=Right;
- bhi.s ReadRepeat;
- ;
- ;------ Increament Plane and repeat Loop: ------
- ;
- addq #1,Plane; INC(Plane);
- cmp Depth,Plane; UNTIL Pland>=Depth;
- blt.s PlaneLoop;
- ;
- ;------ Get Extra-Plane if exists: ------
- ;
- tst Extra(A7);
- beq.s NoExtraPlane; IF ExtraPlane THEN
- ; next lines are equal to them above, but the data isn't saved:
- move.l #0,Location; Location := NIL;
- ExReadRepeat: ; REPEAT
- bsr GetByte; Scratch := GetByte();
- cmp.b #128,Scratch;
- bhi.s ExRepeatNext;
- beq.s ExDoRien; IF Scratch<128 THEN
- move.b Scratch,Byte; Byte := Scratch;
- ExGetMany: ; REPEAT
- bsr GetByte; Scratch := GetByte();
- addq.l #1,Location; INC(Location)
- subq.b #1,Byte; DEC(Byte);
- bpl.s ExGetMany; UNTIL Byte<0;
- bra.s ExDoRien;
- ExRepeatNext: ; ELSIF Scratch>128 THEN
- move.b Scratch,Byte; Byte := Scratch;
- bsr GetByte; Scratch := GetByte();
- ExRepeatIt: ;
- add.l #257,Location; INC(Location,257);
- and.l #$FF,Byte
- sub.l Byte,Location; DEC(Location,Byte);
- ExDoRien:
- cmp.l Location,LineLength;
- bhi.s ExReadRepeat; UNTIL Location>=LineLength;
- NoExtraPlane: ; END;
- ;
- ;------ Increament Line and repeat Loop: ------
- ;
- addq #1,Line; INC(Line);
- cmp AnzLines(A7),Line; UNTIL AnzLines>=Line
- blt LineLoop;
- ;
- ;------ That's it: ------
- ;
- addq #4,A7;
- rts;
- ;
- ;------- Read one Byte: ------
- ; PROCEDURE GetByte();
- GetByte: ; BEGIN
- move.b 0(Buffer,count),Scratch; Scratch := Buffer^[count];
- addq.w #1,count; INC(count);
- cmp.w #512,count;
- blt.s BufferNotEmpty; IF count>=512 THEN
- movem.l D0-D7/A1-A6,-(sp); PUSH(all);
- jsr (GetData); GetData();
- movem.l (sp)+,D0-D7/A1-A6; PULL(all);
- clr count; count := 0;
- BufferNotEmpty: ; END;
- rts; END GetByte;
-
- end
-