From b4425496e443c1d95593a4b1cd22e0c84a114ed0 Mon Sep 17 00:00:00 2001 From: "Christian A. Weber" Date: Fri, 15 May 1992 03:24:13 +0000 Subject: Initial revision --- Source/PushChunk.S | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Source/PushChunk.S (limited to 'Source/PushChunk.S') diff --git a/Source/PushChunk.S b/Source/PushChunk.S new file mode 100644 index 0000000..b021340 --- /dev/null +++ b/Source/PushChunk.S @@ -0,0 +1,121 @@ +** +** $Id: $ +** $Revision: $ +** +** $Filename: PushChunk.S $ +** $Author: Christian A. Weber $ +** $Release: 21.1 $ +** $Date: 92/05/14 22:26:34 $ +** +** iff.library/IFFL_PushChunk +** +** COPYRIGHT (C) 1987-1992 BY CHRISTIAN A. WEBER, BRUGGERWEG 2, +** CH-8037 ZUERICH, SWITZERLAND. ALL RIGHTS RESERVED. NO PART +** OF THIS SOFTWARE MAY BE COPIED, REPRODUCED, OR TRANSMITTED +** IN ANY FORM OR BY ANY MEANS, WITHOUT THE PRIOR WRITTEN PER- +** MISSION OF THE AUTHOR. USE AT YOUR OWN RISK. +** + + + IDNT IFFL_PushChunk + SECTION text,CODE + + INCLUDE "IffLib.i" + + XREF SetError,ClearError + XDEF PushChunkFunc + + +******* iff.library/IFFL_PushChunk ****************************************** +* +* NAME +* IFFL_PushChunk -- Push a new context node on the context stack. +* +* SYNOPSIS +* success = IFFL_PushChunk( iff, type, id ) +* D0 A0 D0 D1 +* +* BOOL IFFL_PushChunk( IFFL_HANDLE, ULONG, ULONG ) +* +* FUNCTION +* Pushes a new context node on the context stack by reading it from the +* stream if this is a read file, or by creating it from the passed +* parameters if this is a write file. Normally this function is only +* called in write mode, where the type and id codes specify the new +* chunk to create. If this is a leaf chunk, i.e. a local chunk inside +* a FORM or PROP chunk, then the type argument is ignored. +* +* INPUTS +* iff - IFF handle +* type - chunk type specifier (ex. ILBM) (ignored for read mode or +* leaf chunks). +* id - chunk id specifier (ex. CMAP) (ignored for read mode). +* +* RESULTS +* Non-zero if successful or 0 if not successful (call IFFL_IFFError() +* to get an IFFL_ERROR_... error code. +* +* SEE ALSO +* IFFL_PopChunk(), IFFL_WriteChunkBytes() +* +***************************************************************************** + +PushChunkFunc: movem.l d0-d3/a2/a5-a6,-(SP) + movea.l a6,a5 ; IFFBase für ClearError() + movea.l a0,a2 ; A2 : IFF-Handle + movea.l iffb_DOSBase(a5),a6 ; A6 : DOSBase + + *** File-Type schreiben falls dies der erste Chunk ist + + tst.l ifffh_FormSize(a2) ; 1. Chunk ? + bne.b .NotFirstChunk ; nee ---> + + move.l ifffh_File(a2),d1 ; Filehandle + move.l SP,d2 ; Type aufm Stack + moveq.l #4,d3 ; Länge: 1 Langwort + JSRLIB Write + cmp.l d3,d0 ; OK geschrieben ? + bne.b .WriteError + add.l d3,ifffh_FormSize(a2) ; FORM-Grösse anpassen +.NotFirstChunk: + + *** Chunk im IFF-Handle initialisieren + + clr.l ifffh_ChunkSize(a2) ; Chunk-Grösse resstten + + move.l ifffh_File(a2),d1 + moveq.l #0,d2 ; Aktuelle Position + moveq.l #OFFSET_CURRENT,d3 + JSRLIB Seek + move.l d0,ifffh_ChunkFPos(a2) ; Chunk-Position eintragen + bmi.b .SeekError ; Error ---> + + *** ID und provisorische Länge schreiben + + move.l ifffh_File(a2),d1 + lea 4(SP),a0 + move.l a0,d2 ; ID und 1 LONG garbage + moveq.l #8,d3 ; ID und provisorische Länge + JSRLIB Write + cmp.l d3,d0 ; OK geschrieben ? + bne.b .WriteError + + *** Okay + + bsr ClearError ; Setzt auch D0 auf TRUE + bra.b .End + + *** Schreibfehler oder Seekfehler + +.SeekError: +.WriteError: moveq.l #IFFL_ERROR_WRITE,d0 + bsr SetError ; Setzt auch D0 auf FALSE + + *** Routine beenden + +.End: move.l d0,(SP) ; D0 in Stack (--> wieder D0) + movem.l (SP)+,d0-d3/a2/a5-a6 + rts + + + END -- cgit v1.2.3