Re: A86: help with game
[Prev][Next][Index][Thread]
Re: A86: help with game
BrncAvFan2@aol.com wrote:
> I am having trouble with this program.
We've all been there. Ok, I revamped your code almost completely. I switched out
the PutSprite routine with my FastSprite routine. (I'm bragging now) I replaced
PutSprite cuz my routine is smaller (probably faster but I haven't checked) and
commented for newbies like yourself. Also my routine xor's the sprite to the
screen...so if you call the routine a second time it will erase the sprite. Read all my
comments.
#include "asm86.h"
#include "ti86asm.inc" ; I took out the other 2 because they weren't needed
.org _asm_exec_ram
call _clrScrn
call _runindicoff
ld b,25
ld c,25
ld hl,PIC
call FastSprite
Main_Prog:
push bc
push hl
call GET_KEY ; this was the main problem causer. Getkey was
; destroying your registers. Fixed via push/pop.
pop hl
pop bc
cp K_EXIT
ret z
cp K_LEFT
jp z,LEFT
cp K_RIGHT
jp z,RIGHT
jp Main_Prog
LEFT:
call FastSprite ; first called to erase pic from old coords
dec b ; modify coords
call FastSprite ; disp the sprite in it' new position
jp Main_Prog ; do it again
RIGHT:
call FastSprite
inc b
call FastSprite
jp Main_Prog
PIC:
.db %00111100
.db %01000010
.db %00111100
.db %00011000
.db %01111110
.db %00011000
.db %00100100
.db %01000010
;FastSprite_______________________________
;Input: Sprite in (HL), (b,c) |
;Output: Sprite xor'ed onto the screen |
;Destroyed: none |
;-----------------------------------------
FastSprite:
push af
push bc
push de
push ix
push hl
push hl ;\
pop ix ; > hl -> ix
ld hl, FSByte ;> point to Tempbyte
ld (hl), c ;> put c into Byte for later use
ld a, b
rrca ;\
rrca ; > divide x by 8 in accumulator
rrca ;/
rld ;> Rotate left 4 bytes
or $FC ;> add a and $FC
ld l, (hl) ;\
ld h, a ; > buncha loading going on
ld a, b ;/
and 7 ;> mask out the shift number
ld d, a ;> save the shift number
ld e, 8
FSLoop:
ld a, (ix) ;> get sprite data
ld b, a
inc ix ;> point to new sprite data byte
ld c, 0 ;> clear c for shift use
ld a, d ;> restore shift # for use
cp 0
jp z, NoShift
ld a, b
ld b, d
FSShift:
srl a ;\
rr c ; \
dec b ; > shift until b < 0
jp z, Shiftend ; /
jp FSShift ;/
NoShift:
ld a, b
Shiftend:
xor (hl) ;> mix the shifted sprite w/screen
ld (hl), a ;> and draw it to the screen
inc hl ;> hl points to next screen byte
ld a, c ;> accumulate the remaining shifted data
xor (hl) ;> mix 'em
ld (hl), a ;> draw it
ld a, 15 ;\
add a, l ; \
ld l, a ; > Inc the <HL> 1 y value.
jp nc, FSNoinc ; /
inc h ;/
FSNoinc:
dec e ; >check if loop is finished
jp nz, FSLoop ;/
pop hl ;\
pop ix ; \
pop de ; > mmmpop boop be doop mmmpop
pop bc ; /
pop af ;/
ret
FSByte: .db $00
.end
> P.S.-If you answer this now, I will probably not have another question for a
> long time.
That's ok, it's what we're here for. Bring'em on.
> THANX
Your welcome. =)
--
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
References: