Re: A86: Reading Level Maps


[Prev][Next][Index][Thread]

Re: A86: Reading Level Maps




Although this is not the smallest way of doing things, this is the fastest
that I could think of.  I usually design programs for speed, not size.

ReadMap:
	ld		b,16				;16 bytes
	ld		hl,Level_1			;hl -> Map data
ReadMapLoop:
	push	bc					;Save bit counter
	ld		a,(hl)				;Put on byte from map data into a
;Here is where u can either use another loop, or do it the following way
(which would be faster).
	bit		7,a					;Test bit 7 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		6,a					;Test bit 6 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		5,a					;Test bit 5 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		4,a					;Test bit 4 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		3,a					;Test bit 3 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		2,a					;Test bit 2 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		1,a					;Test bit 1 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	bit		0,a					;Test bit 0 of the accumulator
	call		nz,Draw_Block		;If it's 1, then draw a block.
	pop		bc					;Get bit counter from stack
	djnz	ReadMapLoop		;Next byte of data.
	ret							;Return

Level_1:
.db %00111100,%11000011
.db %11000011,%00111100
.db %10100101,%01011010
.db %01011010,%10100101
.db %00000000,%11111111
.db %11111111,%00000000
.db %10000001,%01111110
.db %01111110,%10000001

Remember, this routine is BY NO MEANS the smallest way of doing this, however,
it is the FASTEST way I know.  (I'm fairly sure someone will find a faster
way, because I'm only and intermediate programmer.)

Hope this helps!

-Dave


Follow-Ups: