I'm trying to make a graphical program for the Vigenère cipher with z80 assembly and Doors CS's GUI API. I'm trying to obtain text input for the [ plaintext | ciphered message ] and key via GUIRTextMultiline elements, so I can click a button to either encipher or decipher. Though I realize I should use a GUIFind* call, I don't quite understand how I would use it. Could somebody please help me with this?
I don't know of anyone beyond myself and Kerm who have really worked with the DCS GUI in assembly (I suspect there may have been one other person..).
My old ZTris adaptation thread contains some code samples. A relevant bit, from the game options handling:
Code:
Basically, since the GUI stack is in a known state, you need to GUIFindFirst and GUIFindNext to get to the element you're interested in, then read the data from that entry. In this case, it looks like you want the string data from a GUIRTextMultiline, which is a null-terminated string beginning at (entry+6). If you look at my code, I traverse the stack to find the interesting entries, then add some offset and read data out (see the parts after the optsMenuApply label).
My old ZTris adaptation thread contains some code samples. A relevant bit, from the game options handling:
Code:
;config data in gameOptions, one byte
;usage, by bit
;1: scrmLines status (scrambled/unscrambled to send)
;2: status of sendLines (1-3/2-4, I think)
;3: set for two-player, reset for one
;stLevel is the level to begin on (0-9)
;stHeight is starting height (0-5)
openOptsMenu:
call resetAppPage
ld a,(gameOptions)
rra
rra
rra
push af
and 1
ld (optsWinSendRad2+3),a
xor 1
ld (optsWinSendRad1+3),a ;the 'Send x-x' radio buttons reflect the real state now
pop af
rra
and 1
ld (optsWinPlRad2+3),a
xor 1
ld (optsWinPlRad1+3),a ;same for 1/2 players
ld a,GUIRLargeWin
ld hl,optsWinDat
ld de,optsWinLevlSpin-optsWinDat
call pushGUIStack
ld a,GUIRByteInt
ld hl,optsWinLevlSpin
ld de,optsWinLevlSpinLbl-optsWinLevlSpin
call pushGUIStack
ld a,GUIRText
ld hl,optsWinLevlSpinLbl
ld de,optsWinHiSpin-optsWinLevlSpinLbl
call pushGUIStack
ld a,GUIRByteInt
ld hl,optsWinHiSpin
ld de,optsWinHiSpinLbl-optsWinHiSpin
call pushGUIStack
ld a,GUIRText
ld hl,optsWinHiSpinLbl
ld de,optsWinSendRad1-optsWinHiSpinLbl
call pushGUIStack
ld a,GUIRRadio
ld hl,optsWinSendRad1
ld de,optsWinSendRad2-optsWinSendRad1
call pushGUIStack
ld a,GUIRRadio
ld hl,optsWinSendRad2
ld de,optsWinButtonOK-optsWinSendRad2
call pushGUIStack
ld a,GUIRButtonText
ld hl,optsWinButtonOK
ld de,optsWinButtonCancel-optsWinButtonOK
call pushGUIStack
ld a,GUIRButtonText
ld hl,optsWinButtonCancel
ld de,optsWinPlRad1-optsWinButtonCancel
call pushGUIStack
ld a,GUIRRadio
ld hl,optsWinPlRad1
ld de,optsWinPlRad2-optsWinPlRad1
call pushGUIStack
ld a,GUIRRadio
ld hl,optsWinPlRad2
ld de,optsWin_End-optsWinPlRad2
call pushGUIStack
;;I'm too lazy to add optsWinScrmRad1 & 2 now
ld hl,0
call GUIMouse
;;woot, that took too long
optsMenuApply:
call resetAppPage
call GUIFindFirst
push hl
push de
ld de,5
add hl,de
ld a,(hl)
ld (stLevel),a
pop de
pop hl
call GUIFindNext
call GUIFindNext
push hl
push de
ld de,5
add hl,de
ld a,(hl)
ld (stHeight),a
pop de
pop hl
call GUIFindNext
call GUIFindNext
push hl
push de
ld de,6
add hl,de
ld a,(hl)
xor 1
rla
rla
rla
ld hl,gameOptions
res 2,(hl)
or (hl)
ld (hl),a
pop de
pop hl
call GUIFindNext
call GUIFindNext
call GUIFindNext
ld de,6
add hl,de
ld a,(hl)
rla
rla
rla
rla
ld hl,gameOptions
res 3,(hl)
or (hl)
ld (hl),a
jr optsWinReallyClose
optsWinClose:
call resetAppPage
optsWinReallyClose:
ld b,9
call popGUIStacks
pop hl
ret
Basically, since the GUI stack is in a known state, you need to GUIFindFirst and GUIFindNext to get to the element you're interested in, then read the data from that entry. In this case, it looks like you want the string data from a GUIRTextMultiline, which is a null-terminated string beginning at (entry+6). If you look at my code, I traverse the stack to find the interesting entries, then add some offset and read data out (see the parts after the optsMenuApply label).
I believe that ACagliano has also worked with it fairly extensively in ASM, and back in the day Elfprince13 had done some exploration for his iPaint and Strategic (Defense?) games, but sadly didn't get to publish those. Tari, thanks for that explanation, I think it helps a lot. Techno, basically you can use ]GUIFindThis (which I introduced after Tari wrote that code) to jump directly to the beginning of the element that you want, and as he says, the string then starts six bytes offset from that starting address.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
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 vote in polls 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 vote in polls in this forum
Advertisement