0 Members and 1 Guest are viewing this topic.
...(insert header here)Xpos .equ AppBackUpScreenYpos .equ Xpos+1ld A,0ld (Xpos),Ald (Ypos),ALoop:B_CALL _GetCSCcp 1Call Z,Yinccp 2Call Z,Xdeccp 3Call Z,Xinccp 4Call Z,Ydeccp 15jp Z,Quitld A,(Xpos)ld (CurCol),Ald A,(Ypos)ld (CurRow),Ald HL,ItxB_CALL _PutSjp LoopXdec:ld A,(Xpos)cp 0Call NZ,Adecld (Xpos),AretXinc:ld A,(Xpos)cp 15Call NZ,Aincld (Xpos),AretYdec:ld A,(Ypos)cp 0Call NZ,Adecld (Ypos),AretYinc:ld A,(Ypos)cp 7Call NZ,Aincld (Ypos),AretAdec:Dec AretAinc:Inc AretItx: ;"I text".db "I",0Quit:ret
...(insert header here)Xpos .equ AppBackUpScreenYpos .equ Xpos+1 ld A,0 ld (Xpos),A ld (Ypos),ALoop: B_CALL _GetCSC cp 1 jr nz,Yincskip ;If key=1;Yinc: ;Then (the label is commented because it isn't actually used, it's just for clarity) ld A,(Ypos) cp 7 Call NZ,Ainc ld (Ypos),A jr EndKeys ;Else...Yincskip: cp 2 jr nz,Xdecskip ;...If key=2;Xdec: ;Then ld A,(Xpos) cp 0 Call NZ,Adec ld (Xpos),A jr EndKeys ;Else...Xdecskip: cp 3 jr nz,Xincskip ;...If key=3;Xinc: ;Then ld A,(Xpos) cp 15 Call NZ,Ainc ld (Xpos),A jr EndKeys ;Else...Xincskip: cp 4 jr nz,Ydecskip ;...If key=4;Ydec: ;Then ld A,(Ypos) cp 0 Call NZ,Adec ld (Ypos),A jr EndKeys ;Else...Ydecskip: cp 15 jr nz,Quitskip ;...If key=15;Quit: ;Then retQuitskip:EndKeys: ;End (the above Else... ...If's are really ElseIfs, so one End handles them all) ld A,(Xpos) ld (CurCol),A ld A,(Ypos) ld (CurRow),A ld HL,Itx B_CALL _PutS jp LoopAdec: dec A retAinc: inc A retItx: ;"I" text .db "I",0Quit: ret
...(insert header here) ld de,0 ;We will designate e=curRow, d=curColLoop: ;While true B_CALL(_GetCSC) ; getKey->key cp 15 ; ret z ; ReturnIf key=15 dec a ; key-- jr nz,Yincskip ; If key=0 (if original getKey=1);Yinc ; Then inc e ; curRow++ bit 3,e ; jr z,EndKeys ; If curRow=8 dec e ; 7->curRowYincskip: ; End dec a ; key-- jr nz,Xdecskip ; If key=0 (if original getKey=2);Xdec: ; Then dec d ; curCol-- jp p,EndKeys ; If curCol=-1 inc d ; 0->curColXdecskip: ; End dec a ; key-- jr nz,Xincskip ; If key=3 (if original getKey=3);Xinc: ; Then inc d ; curCol++ bit 4,d ; jr z,EndKeys ; If curCol=16 dec d ; 15->curColXincskip: ; End dec a ; key-- jr nz,Ydecskip ; If key=4 (if original getKey=1);Ydec: ; Then add a,e ; jr z,EndKeys ; If curRow!=0 dec e ; curRow--Ydecskip: ; EndEndKeys: ; ld (curRow),de ; e->(curRow) ;d->(curCol) ld a,'I' ; B_CALL(_PutMap) ; Disp 'I' jr Loop ;End
...(insert header here) ld de,0 ;e=curRow, d=curColLoop: B_CALL(_GetCSC) cp 15 ret z dec a cp 4 jr nc,EndKeys dec a sra a jr nz,UpDown;LeftRight: ld c,d adc a,a add a,a dec a add a,d ld d,a and %00010000 jr z,EndKeys ld d,cUpDown: ld c,e neg add a,e ld e,a and %11111000 jr z,EndKeys ld e,cEndKeys: ld (curRow),de ld a,'I' B_CALL(_PutMap) jr Loop
;de = xyloop: bcall(_getCSC) ;a = key dec a ;down is 1, we just keep decreasing jr nz, notDown ;a because the keys are really nicely ;numbered for this inc e ;e is ynotDown: dec a ;left is 2 jr nz, notLeft dec d ;d is xnotLeft: dec a ;right is 3 jr nz, notRight inc d ;d is xnotRight: dec a ;up is 4 jr nz, notUp dec e ;e is ynotUp: dec a ;only things we are interested in ;0 = null, 1, 2, 3, 4 ;all of these will be negative by this point ret p ;return if it's positive ld a, e and 7 ;loop y at 7 ld e, a ld a, d and 15 ;loop x at 15 ld d, a ld (curRow), de ;set the xy ld a, 'I' ;set the char bcall(_putMap) ;display it jr loop