Jump to content
IGNORED

Menu Library


xxl

Recommended Posts

beta menus library. maybe someone find it useful. (libs takes less than 768 bytes - 3 pages)

 

key support: arrow keys, RETURN, Esc

 

 

 


start
        lda #.lo(MO2)
        ldx #.hi(MO2)
        jsr xMenu_OPEN
        sta elemid
        ldx #<hello
        ldy #>hello
        jsr $c642
        jmp start

hello   .byte c'selected ID: '
elemid  .byte $00
        .byte $9b

MO0
        .byte 7         ;         x
        .byte 17        ;         y
        .byte 19        ;         H
        .byte 2         ;         V
        .byte 1         ;         margin x
        .byte 1         ;         margin y
        .byte 3         ;         no of items
        .byte 3         ;         cols
        .byte 0         ;         cursor pos
        .word MO0_E1    ;         items
        .word MO0_E2
        .word MO0_E3
MO1
        .byte 0
        .byte 15
        .byte 7
        .byte 7
        .byte 1
        .byte 1
        .byte 6
        .byte 1
        .byte 0
        .word MO1_E1
        .word M_SPACE
        .word MO1_E2
        .word MO1_E3
        .word MO1_E4
        .word MO1_E5
MO2
        .byte 0
        .byte 23
        .byte 7
        .byte 0
        .byte 1
        .byte 0
        .byte 1
        .byte 1
        .byte 0
        .word MO2_E1
MO2_E1
        .byte c'0'         ; ID
        .byte 0            ; FLAGS
        .word MO1          ; MENU
        .byte d'Start',$9b ; LABEL
M_SPACE
        .byte 0
        .byte $80
        .word 0
        .byte d' ',$9b
MO1_E1
        .byte c'1'
        .byte 0
        .word 0
        .byte d'Test1',$9b
MO1_E2
        .byte c'2'
        .byte 0
        .word MO0
        .byte d'Test2',$9b
MO1_E3
        .byte c'3'
        .byte 0
        .word 0
        .byte d'Test3',$9b
MO1_E4
        .byte c'4'
        .byte 0
        .word 0
        .byte d'Test4',$9b
MO1_E5
        .byte c'5'
        .byte 0
        .word 0
        .byte d'Test5',$9b
MO0_E1
        .byte c'6'
        .byte 0
        .word 0
        .byte d'Test6',$9b
MO0_E2
        .byte c'7'
        .byte 0
        .word 0
        .byte d'Test7',$9b
MO0_E3
        .byte c'8'
        .byte 0
        .word 0
        .byte d'Test8',$9b

xmenu.xex

Edited by xxl
  • Like 5
Link to comment
Share on other sites

now the menu can be used with keyboard shortcuts.
 

 

MO2_E1
        .byte c'1'         ; ID
        .byte $1F          ; SHORTCUT KEY
        .byte 0            ; FLAGS
        .word 0            ; MENU
        .byte d'Label',$9b ; LABEL

xmenu.xex

  • Like 4
Link to comment
Share on other sites

product finished 1.0, further optimizations, takes 3 pages of memory and received a relocator.
adding it to your program, just add it at the beginning, after INIT it will relocate itself (the first byte of the binary is the relocation address, we can also relocate the soft-stack and buffer for the menu background - respectively the second and third addresses at the beginning of the binary)
Of course, if you use xBios, relocations could be done on the fly (without storing source in ram), but for DOS users there was prepared a self-relocating version on INIT.

if we want to use the keyboard shortcuts, we call the xMenu with the deleted C = 0 flag
c = 1 - no keyboard shortcut table will be generated
 

xMenu_OPEN       equ xMenu+$1B

 

        clc             ; + shortcut keys
        ;sec            ; without shortcuts keys
        lda #.lo(MenuObject)
        ldx #.hi(MenuObject)
        jsr xMenu_OPEN

        return: A = selected ID
 

and that's it.

example program:

 

xMenu         equ $5000
xMenu_OPEN    equ xMenu+1B

        org $2000

start   clc             ; + shortcut keys
        ;sec              ; without shortcuts keys
        lda #.lo(MO2)
        ldx #.hi(MO2)
        jsr xMenu_OPEN
        sta elemid
        ldx #<hello
        ldy #>hello
        jsr $c642
        jmp start

hello   .byte c'selected ID: '
elemid  .byte $00
        .byte $9b

MO0
        .byte 9         ;         x
        .byte 17        ;         y
        .byte 25        ;         H
        .byte 2         ;         V
        .byte 1         ;         margin x
        .byte 1         ;         margin y
        .byte 3         ;         no of items
        .byte 3         ;         cols
        .byte 0         ;         cursor pos
        .word MO0_E1    ;         items
        .word MO0_E2
        .word MO0_E3
MO1
        .byte 0
        .byte 15
        .byte 9
        .byte 7
        .byte 1
        .byte 1
        .byte 6
        .byte 1
        .byte 0
        .word MO1_E1
        .word M_SPACE
        .word MO1_E2
        .word MO1_E3
        .word MO1_E4
        .word MO1_E5
MO2
        .byte 0
        .byte 23
        .byte 7
        .byte 0
        .byte 1
        .byte 0
        .byte 1
        .byte 1
        .byte 0
        .word MO2_E1
MO2_E1
        .byte c'0'         ; ID
        .byte 0            ; KEY
        .byte 0            ; FLAGS
        .word MO1          ; MENU
        .byte d'Start',$9b ; LABEL
M_SPACE
        .byte 0
        .byte 0
        .byte $80
        .word 0
        .byte d' ',$9b
MO1_E1
        .byte c'1'
        .byte $1f  ;1      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''1',$9b
MO1_E2
        .byte c'2'
        .byte 0            ; KEY
        .byte 0
        .word MO0
        .byte d'Test2  ',$9b
MO1_E3
        .byte c'3'
        .byte $1a  ;3      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''3',$9b
MO1_E4
        .byte c'4'
        .byte $18  ;4      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''4',$9b
MO1_E5
        .byte c'5'
        .byte $1d  ;5      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''5',$9b
MO0_E1
        .byte c'6'
        .byte $1b  ;6      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''6',$9b
MO0_E2
        .byte c'7'
        .byte $33  ;7      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''7',$9b
MO0_E3
        .byte c'8'
        .byte $35  ;8      ; KEY
        .byte 0
        .word 0
        .byte d'Test ''8',$9b


        run start
 

 

xmenu.xex xMenu.lib

Edited by xxl
  • Like 4
Link to comment
Share on other sites

  • 2 weeks later...

keys: arrows, RETURN, Esc, Space (toggle)

 

new FLAGS: TOGGLE, CHECKED

 

in response we get in A = ID of the selected option, and an array (ended with $ff) with the id of all changed options. Of course, the shortcut keys work where they are defined

xMenuN.obx

Edited by xxl
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...