summaryrefslogtreecommitdiff
path: root/Source/WriteChunkBytes.S
blob: 1de316824a0ca63237f730c35bca02e7b9bf6f64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
**
**	$Id: WriteChunkBytes.S,v 21.1 92/05/15 03:24:59 chris Exp $
**	$Revision: 21.1 $
**
**	$Filename: WriteChunkBytes.S $
**	$Author: chris $
**	$Release: 21.1 $
**	$Date: 92/05/15 03:24:59 $
**
**	iff.library/IFFL_WriteChunkBytes
**
**	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_WriteChunkBytes
		SECTION	text,CODE

		INCLUDE	"IffLib.i"

		XREF	SetError,ClearError
		XDEF	WriteChunkBytesFunc


******* iff.library/IFFL_WriteChunkBytes ************************************
*
*   NAME
*	IFFL_WriteChunkBytes -- Write data into the current chunk
*
*   SYNOPSIS
*	success = IFFL_WriteChunkBytes( iff, buf, size )
*	D0                              A0   A1   D0
*
*	LONG IFFL_WriteChunkBytes( IFFL_HANDLE, APTR, LONG )
*
*   FUNCTION
*	Writes "size" bytes from the specified buffer into the current chunk.
*
*   INPUTS
*	iff   - IFF file handle, from IFFL_OpenIFF().
*	buf   - pointer to buffer area with bytes to be written.
*	size  - number of bytes to write.
*
*   RESULT
*	Non-NULL if the write was successful, or NULL if an error
*	occurred. Call IFFL_IFFError() to know what's going on.
*
*   SEE ALSO
*	IFFL_PushChunk(), IFFL_PopChunk(), IFFL_IFFError()
*
*****************************************************************************

WriteChunkBytesFunc:
		movem.l	d2-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

	*** Daten in Chunk schreiben (Seek-Position ist schon richtig)

		move.l	ifffh_File(a2),d1
		move.l	a1,d2			; Adresse
		move.l	d0,d3			; Länge
		JSRLIB	Write
		cmp.l	d3,d0
		bne.b	.WriteError

	*** Chunk-Grösse updaten

		add.l	d3,ifffh_ChunkSize(a2)

	*** 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:		movem.l	(SP)+,d2-d3/a2/a5-a6
		rts


		END