[Coco] What was the Disk Extended color basic source code for loading a screen dump saved to disk such as a VEF file?

Robert Gault robert.gault at worldnet.att.net
Sun Jan 17 12:33:21 EST 2010


RJLCyberPunk wrote:
> So does anyone has the BASIC source code around? If so please post it...
>

Here are two very simple Basic programs for saving and loading an 
HSCREEN. As written HLOAD assumes the screen was HSCREEN4 but you can 
change that.

HSAVE.BAS
10 WIDTH32:PMODE0:PCLEAR1
20 SAVEM"PALETTE",&HFFB0,&HFFBF,0
30 POKE&HFFA1,&H30:POKE&HFFA2,&H31:SAVEM"HSCR1",&H2000,&H5FFF,0
40 POKE&HFFA1,&H32:POKE&HFFA2,&H33:SAVEM"HSCR2",&H2000,&H5FFF,0
50 POKE&HFFA1,&H39:POKE&HFFA2,&H3A

HLOAD.BAS
10 WIDTH32:PMODE0:PCLEAR1:POKE&HE6C6,&H21
20 LOADM"PALETTE"
30 POKE&HFFA1,&H30:POKE&HFFA2,&H31:LOADM"HSCR1"
40 POKE&HFFA1,&H32:POKE&HFFA2,&H33:LOADM"HSCR2"
50 POKE&HFFA1,&H39:POKE&HFFA2,&H3A
60 HSCREEN4
70 GOTO70

If you know that the file is a single screen 640x200x4 vef NTSC artifact 
file and have placed the file on a Disk Basic disk, then you could use 
this combination of Basic and ml programs to load the image.

10 CMP:WIDTH80:LOADM"VIEWVEF"
20 INPUT"Please indicate the image drive# ->";DR
30 IF DR <0 OR DR>3 THEN CLS:GOTO20
40 DRIVE DR:FOR I=1TO4
50 READ F$:OPEN"I",#1,F$
60 EXEC:CLOSE
70 FORT=1TO2000
80 NEXT T,I
90 HSCREEN0:CMP:CLS
100 END
110 DATA "name.VEF"

* This program will load vef files that have the format
* 160x200x4 using artifact colors. These files have an
* 18 byte header as follows. R.Gault Jan. 12, 2010

header	rmb	1	??
pages	rmb	1	should be 1 for one screen
palette	rmb	16	but only four entries present for this type

* This is fixed because of the 18 byte header and screen size of
* 160x200  $7D00+$12
filesize	equ	$7d12

	org	$e00
start	orcc	#$50
	sts	stack2
	lds	#stack	get the stack out of the way of the screen
	lbsr	clock	check for 2MHz use for disk I/O
	sta	$ffd9	fast CPU
	lda	$e06f	HSCREEN4 init value
	ora	#$20	HSCREEN4 set to 640x200x4
	sta	$e06f	set a new one
	lda	#1	disk buffer
	sta	$6f	set console out for disk read
	ldy	#$ffb0	GIME palettes
	lbsr	read	skip one byte
	lbsr	read	get number of screens
	cmpa	#1
	lbne	error
	ldb	#4	get four palette colors
a@	bsr	read
	sta	,y+
	decb
	bne	a@
	ldb	#18-6	skip unused palette entries
b@	bsr	read
	decb
	bne	b@

	ldb	#4	HSCREEN#
	jsr	$e6a5	set HSCREEN to value in regB
	lbsr	clean	blank the screen
	ldd	#$c000	*$60000
	std	$ff9d	point video to start of graphics screen
	ldd	#$3031	Start screen at $60000
	std	$ffa1	set 2 MMU blocks
	incb
	stb	$ffa3	set a third MMU block
	ldx	#$2000	fill the screen
	ldy	#$6000
a@	bsr	read
	sta	,x+
	leay	-1,y
	bne	a@

	ldd	#$333a
	std	$ffa1
	incb
	stb	$ffa3	reset 2 MMU blocks and update third
	ldx	#$2000
	ldy	#$2000
a@	bsr	read
	sta	,x+
	leay	-1,y
	bne	a@

	lda	#$39	restore the last MMU block
	sta	$ffa1
	ldx	#$ffd8	return CPU to entry speed
	lda	speed
	sta	a,x	reset CPU clock speed
	lds	stack2
	andcc	#$af
	rts		return to Basic

exit	clr	$e6	used if there was an error
	lda	#$1d
	sta	$e06f
	clra
	jsr	$e019
	ldx	#$ffd8
	lda	speed
	sta	a,x	reset CPU clock speed
	lds	stack2
	andcc	#$af
	jmp	$adfb

read	tst	speed	use fast I/O if possible
	bne	a@
	sta	$ffd8
a@	jsr	$a176
	tst	speed
	bne	b@
	sta	$ffd9
b@	rts

clock	clrb		test current CPU clock speed
	bsr	vsync
	lda	$ff02
a@	incb
	lda	$ff03
	bpl	a@
	clra
	cmpb	#$c0
	bhi	setspd
	inca
setspd	sta	speed
	rts

speed	rmb	1

vsync	lda	$ff02
a@	lda	$ff03
	bpl	a@
	lda	$ff02
	rts

error	clr	$6f
	ldx	#mesg-1
	jsr	$b99c	PRINT ERROR AND RETURN TO BASIC
	bra	exit
mesg	fcc	/SORRY BUT BAD FILE FORMAT!/
	fcb	0

clean	lda	#$34	erase the screen
	sta	$ffa2
	sts	stack1
	lds	#$6000
	clrb
	ldx	#0
	ldy	#0
	ldu	#0
a@	clra
b@	pshs	d,x,y,u
	cmps	#$4000
	bne	b@
	lds	#$6000
	lda	$ffa2
	anda	#$3f
	cmpa	#$30
	beq	c@
	dec	$ffa2
	bra	a@
c@	lds	stack1
	lda	#$3a
	sta	$ffa2
	rts
	
	rmb	100
stack	equ	*
stack1	rmb	2
stack2	rmb	2

	end	start



More information about the Coco mailing list