MaxCoderz

for your 1 bit pleasure!

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat 19 Nov, 2011 11:27 am 
Offline
Extreme Poster

Joined: Fri 07 Jul, 2006 2:39 pm
Posts: 336
Hello everyone, i know there are still a few people who frequent this board even if it's not very active, so i thought i'd pose a little question and hopefully see some familiar faces :)

Right now, i've got some code (basically, a pause function):
Code:
;##########################
;#WAIT2ND
;#Wait for the 2nd key to be pressed.
;# If 2nd is currently held, we first
;# wait for it to be released then
;# check if it has been pressed again.
;# Also, displays the gbuf
;#Explanation: b starts off at 2 (see
;# inc b). If 2nd is pressed, we jump to
;# loop2, so the djnz will always drop b
;# to 1, never 0, until we release 2nd.
;# this is so that the player doesn't
;# accidentally skip a message
;##########################
wait2nd:
    call drawgbuf
    ld b,1
    jr w2_loop2
w2_loop:
    ld b,0
w2_loop2:
    inc b
    ld a,$BF        ;group 7
    out (1),a
    in a,(1)
    cp 223          ;2nd
    jr nz,w2_loop   ;if 2nd isn't pressed, repeat loop
    djnz w2_loop2
    ret
...which works fine, but then i thought that there will probably be more instances where the user not releasing 2nd soon enough might cause them to select/do things they didn't want to, so maybe a separate "wait2ndReleased" function might be handy.
Code:
wait2ndReleased:
    ld a,$BF        ;group 7
    out (1),a
w2R_loop:
    in a,(1)
    cp 223          ;2nd
    jr z,w2R_loop
    ret
The thing is i figure this would eat up a lot of battery power, so maybe i should throw in a halt or two. This code then made me think about how several years ago, it seemed to be common practice to "clear" the port before reading from it. Is there any reason for doing that (apart from maybe reading leftover keypresses)?

So i've got two questions, the first being whether it'd be worthwhile to throw in a halt or two in the w2r routine, the second about clearing the key port before reading from it.

Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Sun 20 Nov, 2011 12:06 pm 
Offline
Calc King

Joined: Sat 05 Aug, 2006 7:22 am
Posts: 1513
The keypad thingy maintains a set of active groups, so if anything was already active, you're now reading from 2 (or more) groups at the same time. Typically group $BF or $7F or $FE would be the last active group (from scanning the entire keypad), and in none of those cases would 2nd clash with any other key ($7F has no keys, $FE only has 4 while 2nd is at the 6th bit).
But just in case, I'd throw in a quick ld a,$FF \ out (1),a

Halts should work yes


Top
 Profile  
Reply with quote  
PostPosted: Mon 21 Nov, 2011 12:27 am 
Offline
Extreme Poster

Joined: Fri 07 Jul, 2006 2:39 pm
Posts: 336
Thanks, i figure it'll almost never be an issue, only if you want to read keys which share the same value in two different groups. Honestly, it doesn't really matter to me if you can also use another unintended key, so long as it doesn't overlap with a key you are using. I remember playing certain games back in the day and finding out that certain keys would do things, like the graph keys would move you (maybe it was falldown?), i dunno. Anyway, thanks for the response :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB ® Forum Software © phpBB Group | DVGFX2 by: Matt