Difference between revisions of "256 byte Overscan MEGATEXT Intro - (features 50Hz fullscreen scroll)"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(Created page with "<pre> ;--------------------------------------------------------------------- ; 256 byte Overscan MegaText Intro v1.1b ; (7DX Demo Party 2011 Release) ; ; for Amstrad 464/664...")
(No difference)

Revision as of 05:26, 30 December 2011

	;---------------------------------------------------------------------
	;	256 byte Overscan MegaText Intro v1.1b
	;	(7DX Demo Party 2011 Release)
	;
	;	for Amstrad 464/664/6128 computers
	;
	;	by matahari - (Dec 24, 2011)
	;
	;	Featuring;
	;	 - Greetings message via 50Hz CRTC hardware scroll
	;	 - 100% overscan (full) screen size
	;	 - Complete Amstrad palette (27 colours) on screen at once
	;	 - And, all in 256 bytes!
	;---------------------------------------------------------------------

		LET ADDR_Start 		= &400
		LET ADDR_TextMap		= ADDR_Start + 256

		LET CONST_TotalRasterLines	= 269

		LET VAR_BgrndColour		= ADDR_Start - 1
		LET VAR_FlipFlop		= VAR_BgrndColour - 1
		LET VAR_LineSkipMinus		= CONST_TotalRasterLines * -9
		LET VAR_LineSkipPlus		= CONST_TotalRasterLines * 9

		VAR_XOR			equ 1 xor 0

		run start
		org ADDR_Start

start:	;---------	Generate a dummy interrupt handler ---------------------------

		ld	hl,&c9fb
		ld	(&0038),hl

	;---------	Set CRTC Registers -------------------------------------------

		ld	hl,CRTC_Data
loopCRTC:		ld	a,(hl)
		ld	b,&bc + 1
		outi
		ld	b,&bd + 1
		outi
		inc	a
		jr	nz,loopCRTC

	;---------	Display text message -----------------------------------------

		ld	hl,ADDR_TextMap 
		ld	de,Message

loopText:		push	de
		push	hl
		ld	a,2
		call	&bc0e
		pop	hl
		pop	de

		ld	a,(de)
		cp	255
		jr	z,loopExec

		call	&bb5a

		inc	de
		push	de

	;---------	Grab pixels of displayed char --------------------------------

		ld	de,&c000
		ld	a,8
		ld	c,&40
outer:		ex	af,af'
		ld	iy,vangelis + 1
		ld	(iy),%10000000
		call	Proc_FlipFlop
inner:		call	Proc_FlipFlop
		or	a
		jr	z,bitBckgrndA
		ld	a,&55
		jr	bitBckgrndB
bitBckgrndA:	ld	a,&57
bitBckgrndB:	ld	(VAR_BgrndColour),a
		ld	a,(de)
vangelis:		and	0
		jr	z,blit
		ld	a,c

		;*********************************

blit:		push	hl
		push	de
		push	bc
		ld	de,9
		ld	b,26
blitText:		add	hl,de
		or	a
		jr	z,blitBckgrnd
		ld	(hl),c
		inc	c
		jr	blitSkip

blitBckgrnd:	push	af
		ld	a,(VAR_BgrndColour)
		ld	(hl),a
		pop	af

blitSkip:		djnz	blitText
		pop	bc
		pop	de
		pop	hl

		;*********************************

		inc	hl
		rr	(iy)
		jr	nc,inner

		inc	hl
		
		ld	a,8
		add	a,d
		ld	d,a

		push	bc
		ld	bc,25*9
		add	hl,bc
		pop	bc

		ex	af,af'
		dec	a
		jr	nz,outer

		pop	de
		jr	loopText

	;*********************************************************************
	;	MAIN LOOP - INITIALIZE!
	;*********************************************************************

loopExec:		ld	hl,ADDR_TextMap + VAR_LineSkipPlus

					; Checking VBlanking only for once!
					; Rest of the code will be manually synced
					; via precise t-state calculations.
		ld	b,&f5
waitVBlanking:	in	a,(c)
		rra
		jr	nc,waitVBlanking

		halt
		di

	;---------	X-Pos Alignment ----------------------------------------------

		ld	a,(hl)		; waste time! => 7 cycles
					; Aligns perfect on WinApe.

					; If you need precise
					; alignment on an original Amstrad,
					; you need to comment out this line
					; OR replace it with a NOP!

					; No worries, intro size will not
					; exceed 256 bytes either way ;-)

	;*********************************************************************
	;	MAIN LOOP - BEGIN
	;*********************************************************************

loopBegin:		ld	de,VAR_LineSkipMinus + 9
		add	hl,de

	;---------	Wait for perfect sync! ---------------------------------------

		ld	b,203		; waste time!
waste1:		nop			; waste time!
		add	ix,ix		; waste time!
		djnz	waste1		; waste time!

	;---------	Start CRTC code ----------------------------------------------

		ld	de,CONST_TotalRasterLines
		ld	bc,&7f00
		out	(c),c

crash:		outi
		inc	b
		outi
		inc	b
		outi
		inc	b
		outi
		inc	b
		outi
		inc	b
		outi
		inc	b
		outi
		inc	b
		outi
		inc	b
		outi
		inc	b

		ld	a,(hl)		; waste time!
		nop			; waste time!

		dec	de
		ld	a,d
		or	e
		jr	nz,crash

	;---------	Raster colour = Black ----------------------------------------

		ld	a,&54
		out	(c),a

		nop			; waste time!
		ld	b,(hl)		; waste time!
		ld	b,224		; waste time!
waste2:		djnz	waste2		; waste time!

loopEnd:		jr	loopBegin

	;*********************************************************************
	;	MAIN LOOP - END
	;*********************************************************************


	;---------	Procedure for Flip/Flop --------------------------------------

Proc_FlipFlop:	ld	a,(VAR_FlipFlop)
		xor	VAR_XOR
		ld	(VAR_FlipFlop),a
		ret

	;---------	CRTC Data ----------------------------------------------------

CRTC_Data:	db	1,54			; set display width
		db	2,50		; set horizontal sync
		db	6,34		; set display height
		db	7,35		; set vertical sync
		db	255		; => EXIT LOOP

Message:	db	'  WELCOME TO 7DX2011 ',255