;/* depack4.s */

;****************************************************************************
;*
;*  Copyright (C) 2000-2001 Eli-Jean R. Leyssens, aka Pervect of Topix
;*
;*  This file is part of the CodePressor package.
;*
;*  CodePressor is free software; you can redistribute it and/or modify
;*  it under the terms of the GNU General Public License as published by
;*  the Free Software Foundation; either version 2 of the License, or
;*  (at your option) any later version.
;*
;*  CodePressor is distributed in the hope that it will be useful,
;*  but WITHOUT ANY WARRANTY; without even the implied warranty of
;*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;*  GNU General Public License for more details.
;*
;*  You should have received a copy of the GNU General Public License
;*  along with CodePressor; if not, write to the Free Software
;*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
;*
;*  Eli-Jean R. Leyssens can be reached via email at eli@dnd.utwente.nl
;*  snail: E-J.R. Leyssens, Schivelbeinerstr. 5, 10439 Berlin, Germany
;*
;***************************************************************************/

		AREA 	|C$$code|, CODE, READONLY

r0	RN 0
r1	RN 1
r2	RN 2
r3	RN 3
r4	RN 4
r5	RN 5
r6	RN 6
r7	RN 7
r8	RN 8
r9	RN 9
r10	RN 10
r11	RN 11
r12	RN 12
r13	RN 13
link	RN 14
		EXPORT	|depack4_part0_begin|
		EXPORT	|depack4_part0_start|
		EXPORT	|depack4_part0_jump_program|
		EXPORT	|depack4_part0_end|

|depack4_part0_begin|
; /////////////////////////////////////////////////////////////////////////
|depack4_part0_start|
;		adr	r4, |depack4_part0_begin|
		adr	r2, depack4_data
|depack4_main_loop|
		tst 	r4, #3
 		strb 	r5, [ r4], #-1	; We don't care about overwrite of
					; lower byte of part0_start
		ldreqb 	r3, [ r2], #1
		andeqs 	r0, r3, #&f0
		beq     depack4_done
	   	movs 	r3, r3, lsr #1
		ldrccb	r5, [ r4, r0, lsr #2]
		ldrcsb	r5, [ r2], #1
		b	depack4_main_loop
depack4_done
		swi	"XOS_SynchroniseCodeAreas"
|depack4_part0_jump_program|
		b	|depack4_part0_jump_program|

|depack4_data|
; /////////////////////////////////////////////////////////////////////////
|depack4_part0_end|

		END
