*
*   turboevd.s - "startup" code
*   Copyright (C) 1997 Aki Laukkanen
*
*   This program 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.
*
*   This program 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 this program; if not, write to the Free Software Foundation,
*   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*

;DEBUG = 1

	XDEF    _evd_name
	XDEF    _evd_id
	XDEF    _evd_author

	XREF    _evd_openscreen
	XREF    _evd_closescreen
	XREF    _evd_refresh
	XREF    _evd_loadrgb32

*
* includes
*
*

	include "exec/types.i"
	include "utility/tagitem.i"
	include "shapeextvideo.i"
	include "turboevd_rev.i"

	include "lvo/exec_lib.i"

	section evd,code

	IFND    DEBUG
evd_start
	EVHEADER _evd_tags
	ENDC

* for debugging purposes only

	IFD     DEBUG

start
	move.l  4.w,a6
	moveq   #0,d0
	lea     utilname,a1
	jsr     (_LVOOpenLibrary,a6)
	move.l  d0,a6
	lea     intags,a0
	lea     outtags,a1
	sub.l   a2,a2
	jsr     _evd_openscreen
	lea     outtags,a1
	move.l  (4,a1),a2
	move.l  a2,-(sp)
	move.l  (12,a1),a0
	move.l  a0,a1
	move.l  a0,a3
	adda.l  #640*480*2,a1
	lea     _test_image,a2
.loop
	move.l  (a2)+,(a0)+
	cmp.l   a0,a1
	bne.s   .loop
	move.l  (sp)+,a2

;    lea     paltags,a0
;    sub.l   a1,a1
;    jsr     _evd_loadrgb32

	sub.l   a0,a0
	sub.l   a1,a1
	jsr     _evd_refresh

	move.l  a3,a0
	adda.l  #640*480/4,a3
.loop2
	move.l  #$00000000,(a0)
	adda.l  #32,a0
	cmp.l   a0,a3
	bne.s   .loop2

	jsr     _evd_refresh
	jsr     _evd_closescreen
	move.l  a6,a1
	move.l  4.w,a6
	jsr     (_LVOCloseLibrary,a6)
	rts

utilname
	dc.b    'utility.library',0

	cnop    0,4
intags
	dc.l    SHEV_ScreenX,640
	dc.l    SHEV_ScreenY,480
	dc.l    SHEV_DisplayID,$39024
	dc.l    SHEV_VideoMode,VMODE_15BIT
	dc.l    TAG_END,0
outtags
	dc.l    SHEV_Context,0
	dc.l    SHEV_ScreenBase,0
	dc.l    SHEV_Screen,0
	dc.l    SHEV_BytesPerRow,0
	dc.l    SHEV_RefreshType,0
	dc.l    TAG_END,0
paltags
	dc.l    SHEV_ColorTable,_test_pal+4

	ENDC

*
* This data hunk contains various taglists and other data needed by
* the driver.
*

	section paa,data

_evd_name   dc.b    'TurboEVD',0
_evd_id     VSTRING
_evd_verstag VERSTAG
_evd_author dc.b    'Aki Laukkanen (amlaukka@cc.helsinki.fi)',0

	IFD     DEBUG
_test_image
	incbin  "test2.hic"
_test_pal
	incbin  "test.pal"
	ENDC

	cnop    0,4
_evd_tags
	dc.l    SHEV_Level,2
	dc.l    SHEV_Version,VERSION
	dc.l    SHEV_Revision,REVISION
	dc.l    SHEV_Name,_evd_name
	dc.l    SHEV_ID,_evd_id
	dc.l    SHEV_Author,_evd_author
	dc.l    SHEV_OpenScreen,_evd_openscreen
	dc.l    SHEV_CloseScreen,_evd_closescreen
	dc.l    SHEV_Refresh,_evd_refresh
	dc.l    SHEV_LoadRGB32,_evd_loadrgb32
	dc.l    TAG_END
