A86: Stupid program
[Prev][Next][Index][Thread]
A86: Stupid program
It's not like me to ask for help but now I'm desperate.
The purpose of the enclosed program is to display this
cute little guy on the screen and be able to smooth scroll
him around. The display part works the smooth scroll doesn't
would someone please help me?
--
Tercero -- Email: mailto:tercero@busprod.com
"The stone the builders rejected has become the capstone;"
--Psalms 118:22
"Everyone who falls on that stone will be broken to pieces,
but he on whom it falls will be crushed."
--Luke 20:18
#include "asm86.h"
#include "ti86asm.inc"
.org _asm_exec_ram
Initialization:
call _clrLCD ; clear the screen
ld bc, $0101 ; pic position pointer
ld ix, Down ; load the pic
call PutSprite ; disp the pic
Waitkey:
call _getkey ; look for keys
nop ; take 5 for the batteries
nop ; <inhale>
nop ; <exhale>
nop ; <inhale>
nop ; <exhale>
cp kExit ; Exit ?
ret z ; Exit !
cp kUp ; Is Up pressed?
jp z, MUp ; Go there
cp kDown ; blah
jp z, MDown ; blah
cp kLeft ; blag (oops)
jp z, MLeft
cp kRight
jp z, MRight
jp Waitkey ; no keys pressed? do it again!
MUp:
ld ix, Down ; load the pic
call PutSprite ; erase old pic
dec c ; move pic position
ld ix, Down ; ld pic
call PutSprite ; disp new pic
jp Waitkey ; do it again and again and again
MLeft:
ld ix, Down ; come on the procedure is the same
call PutSprite ; for the rest of the program
dec b
ld ix, Down
call PutSprite
jp Waitkey
MRight:
ld ix, Down
call PutSprite
inc b
ld ix, Down
call PutSprite
jp Waitkey
MDown:
ld ix, Down
call PutSprite
inc c
ld ix, Down
call PutSprite
jp Waitkey
Down: .db %00111110,%01010101,%01010101,%01000001
.db %00111110,%01001001,%00110110,%00000000
;PutSprite
;Input: bc = x,y; ix = 8x8 sprite location
;Output: sprite drawn; ix points to next sprite (if your sprites follow
; in sequence); hl and and de destroyed
PutSprite:
ld h,63 ;shifted to $fc with add hl,hl
ld a,c
add a,a ;a*4
add a,a
ld l,a
add hl,hl ;hl*4 (what was c has been mlt by 16
add hl,hl
ld a,b ;a/8
rra
rra
rra
or l ;add to more significant bytes
ld l,a
ld a,7 ;use bottom 7 bits for counter
and b
ld d,a ;save counter copy in d
ld e,8 ;8 rows
push bc
ps_loop:
ld b,d ;get saved bit offset in b
ld a,(ix) ;get this byte of the sprite in a
inc ix ;point ix to the next byte of the sprite
ld c,0
call bit_shift
xor (hl) ;change this to or if you want
ld (hl),a
inc l
ld a,(hl)
xor c ;also changable to or (if you changed the first)
ld (hl),a
ld a,15 ;add 15 to hl (now ready for next row)
call add_hl_a
dec e ;counter (8 rows)
jr nz,ps_loop
pop bc
ret
add_hl_a: ;add hl,a
add a,l
ld l,a
ret nc
inc h
ret
bit_shift: ;while(b=<0)
dec b ; a>>c
ret m
srl a
rr c
jr bit_shift
.end