;                                 ;
;        A s a h i k a w a        ;
;                                 ;
;       64b city  landscape       ;
;                                 ;
;       Mathieu 'p01' Henri       ;
;       http://www.p01.org/       ;
;                                 ;
;       january  21st, 2007       ;
;                                 ;

org 100h

mov al,13h
int 10h
les  bp,[bx]
main:
	mov		ax,di
	cdq
	mov		bx,320
	div		bx			; ax = y, dx = x

	sub		dx,160
	mov		bx,dx		; bx = x-160

	inc		ax
	mov		cx,ax		; bp = y+1

	mov		ah,32
	cwd
	div		cx			; ax = perspScale =	~y projected

	imul	bx,ax		; bx = (x-160)*perspScale =	~x projected

	add		ax,si		; frame	offset

	and		al,240
	shr		bx,12

	xlat				; buildings 'LUT'

	xor		ax,bp

	push	di
loop_y:
		or		al,16
		stosb
		sub	 di,321
		inc	 ax
		and	 ax,15
	jnz		loop_y
	pop		di
	inc		di

	jno	   main
	inc		si			; next frame
jmp	   main
db	   03h				; <3
