A86: Re: Stupid program


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

A86: Re: Stupid program




>Tried it, failed it that's why I'm desperate.

Here's some code (a lot) that scrolls up and down, with screen edge
detection.  It's very different from the code you posted.  It's not
optimized, and sorta slow.  A future version of this code won't put the
sprite every time it loops, just the first time.  This isn't all my own
code.  I had a putsprite/picture that used LDI, but I didn't know about
the PO thing until I saw it somewhere?  Sorry about all this code, but I
don't have internet access right now.

#include "ti86asm.inc"
#include "asm86.h"
.org _asm_exec_ram
	call _clrLCD
	ld hl,BMAN	;HL->sprite
	ld de,$fc55	;DE->place to put it
	push de		;Save both
	push hl			
	call PutSprite	;Put the sprite
	pop hl		;Get both back
	pop de
Loop:
	push hl		;GET_KEY destroys both, Right?
	push de
	call GET_KEY	;Get that key.
	pop de
	pop hl
	cp K_UP
	call ClearSprite ;Clear 8*8 chunk
	push hl		;My moves destroy hl :(
	call z,MovUp1	;Move Up
	pop hl
	cp K_DOWN
	push hl
	call z,MovD1	;  "  Down
	pop hl
	cp K_EXIT
	ret z
	push de		;PutSprite destroys hl/de
	push hl
	call PutSprite	;Put the sprite
	pop hl
	pop de
	jr Loop
MovUp1:
	ld h,d		;DE->HL
	ld l,e		;HL is used as a check
	ld bc,16+$FC00	;Check if sprite moves 
	or a		;off screen by subtract
	sbc hl,bc	;FC10 from hl
	ret c		;ret if wrapped back around
	ld bc,$fc00	;Add FC00 back to hl
	add hl,bc
ScrUp:
	ld d,h		;Save the changes to hl
	ld e,l		;back to de
	ret
MovD1:
	ld h,d		
	ld l,e
	push hl		;Save hl
	ld bc,128	;128=16+(16*8)
	add hl,bc	;checks bottom of sprite
	pop hl		;Get hl
	ret c		;Ret if wrapped around
	ld bc,16
	add hl,bc
	jr ScrUp	;Save changes to hl
ClearSprite:
	push af
	push hl
	push de
	ld b,8
	ex de,hl
CSLine:
	ld (hl),0
	ld a,l
	add a,16
	ld l,a
	jr nc,CSLineCont
	inc h
CSLineCont:
	djnz CSLine
	pop de
	pop hl
	pop af
	ret
PutSprite:
	ld bc,8		;8 lines
Putline:
	ldi		;(HL)->(DE)
	ret po		;
	ld a,e
	add a,15	;16 bit add
	ld e,a		;DE=DE+8
	jr nc,Putline
	inc d
	jr Putline	;Write B lines
BMAN:
	.db %10111100,%11001110,%01000010,%00111100
	.db %01011010,%01000010,%01111110,%00100100
.end


Sam



_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]


References: