;===================================================== ; WaitKey- Waits and gets a key into register a ;===================================================== waitkey: ei WKA_loop: HALT icall(_getcsc) or a jr z, WKA_loop WK_RET: ;ret=$C9 nop ;Check for certin keys cp gClear jr z,Terminate cp gSto jr z,Saveandquit ret AWaitkey: call DoEvents ei HALT icall(_getcsc) or a jr z, AWaitkey jr WK_RET ;====================================================== ; AnimateBack - Animates background (motion or gray) ;====================================================== AnimateBack: ei ;Set up Vars ld hl,(spritepoint) ld bc,32 add hl,bc ld bc,$180E ;b=24, c=RRCA ;Check Direction ld a,(animback) cp $80 ;Check for scroll mode jr nc,$+4 ;If not then... ld b,32 ;Full Background Mode xor 1 ;Toggle Mode ld (animback),a ld a,c jr z,$+4 AnimateLeft: ld a,$06 ;a=RLCA ld (AnimateOp+1),a AnimateBackLoop: AnimateOp: rrc (hl) inc hl djnz AnimateBackLoop AnimateNext: ret Terminate: ld hl,0 ld (resumedata),hl ld (resumedata+2),hl ; ld sp,(backupsp) ; ret SaveAndQuit: ld sp,(backupsp) call FixBack ret ;====================================================== ; Random number routine stolen from CrASH, modified ;====================================================== DQRand: RandA: ld a,$94 push hl RandHL: ld hl,$4C79 inc l dec h randdata1 = RandA+1 randdata2 = RandHL+1 ld (randdata2),hl rlca rlca sub h add a,l pop hl ld (randdata1),a srl a ret ;=================================================== ; ImpendingBattle-BattleOff/GetBattle (mode key) ;=================================================== ImpendingBattle: ld a,(fight) or a jr z,MakeFight ld a,255 MakeFight: inc a ld (fight),a ret ;========================== ; TextBox1-Draws box ;========================== TextBox1: ;Refresh Display call renderscreen ld a,8 call SetSpriteHeight ld bc,$0408 txtbox1: ld hl,whitey push bc call PutSprClp pop bc inc c ld hl,whitey2 push bc call PutSprClp pop bc dec c ld a,b add a,8 ld b,a cp 92 jr nz,txtbox1 ld b,8 ld a,4 ld l,9 ld ix,bar call PutSprite ld b,8 ld a,91 ld l,9 ld ix,bar call PutSprite call fastcopy ;Set the next text location ld hl,$0906 ld (pencol),hl ret ;====================================== ; vDispHL- Displays HL in small font ;====================================== vDispHL: ;83/83+ code ; bcall(_SETXXXXOP2) ; bcall(_OP2TOOP1) ; bcall(_DISPOP1A) ;82 code: push de push hl ld de,op1+5 xor a ld (de),a vdhlRepeat: icall(_divhlby10) add a,'0' dec de ld (de),a ld a,h or l jr nz,vdhlRepeat ex de,hl bcall(_vputs) pop hl pop de ret