; Update enemy x,y positions. ld ix,ashdir ; point to enemy Ash data. call enemy ; move Ash down and left/right. ; ..... code continues... ; -------------------------------------------------------------- ; UPDATE ENEMY. ; Calculate new x,y positions for an enemy car. ; IX = start of enemy data block. enemy ld a,(ix+0) ; test direction. cp 0 ; moving left (0=left, 1=right)? jp nz,enem0 ; no - then enemy is moving right. ; Direction: Left - test left border. ld a,(ix+2) ; load enemy's x-coordinate. cp leftb ; compare it to left border constant. jp nc,+ ; branch if accumulator (x) > leftb. ; else - enemy is on the left border ld a,1 ; shift direction to 'right'. ld (ix+0),a ; load it into direction byte. jp enem1 ; skip forward to vertical movement. ; Direction: Left - subtract from enemy x coordinate. + ld b,hspeed ; load horizontal speed into B. ld a,(ix+2) ; load enemy x into A. sub b ; subtract hspeed from x (move left). ld (ix+2),a ; update enemy x coordinate. jp enem1 ; skip forward to vertical movement. ; Direction: Right - test right border. enem0 ld a,(ix+2) ; load enemy x. cp rightb ; compare it to right border. jp c,+ ; skip if rightb > accumulator (x). xor a ; else - shift direction to 0 = left. ld (ix+0),a ; load new value into direction var. jp enem1 ; forward to vertical movement. ; Direction: Right - add to enemy x coordinate. + ld b,hspeed ; load hspeed constant into B. ld a,(ix+2) ; load enemy x into A. add a,b ; add hspeed to enemy x. ld (ix+2),a ; update enemy x coordinate. ; Vertical movement for enemy (move enemy car down). enem1 ld a,(ix+1) ; load enemy y into A. add a,espeed ; add constant enemy vertical speed. ld (ix+1),a ; update enemy y. ret