Keyboard input/Obtain a Y or N response: Difference between revisions
Keyboard input/Obtain a Y or N response (view source)
Revision as of 05:30, 30 October 2021
, 2 years ago→{{header|Z80 Assembly}}
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 2,143:
CrLf(0);
]</lang>
=={{header|Z80 Assembly}}==
{{works with|Amstrad CPC}}
This simple template can be <code>CALL</code>ed to wait for a Y/N response and act based on that. This particular template is limited in that the code that gets executed based on the response can't be changed at runtime (at least not without self-modifying code.)
<lang z80>wait_for_key_input:
call &BB06 ;bios call, waits until key is pressed, returns key's ASCII code into A
and %11011111 ;converts to upper case
cp 'Y'
jp z,User_Chose_Yes
cp 'N'
jp z,User_Chose_No
jp wait_for_key_input
User_Chose_Yes:
;your code for what happens when the user types "Y" goes here
ret
User_Chose_No:
;your code for what happens when the user types "N" goes here
ret</lang>
{{omit from|GUISS}}
|