xxl Posted March 26, 2020 Share Posted March 26, 2020 (edited) 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 March 26, 2020 by xxl 5 Quote Link to comment Share on other sites More sharing options...
xxl Posted March 26, 2020 Author Share Posted March 26, 2020 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 4 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted March 26, 2020 Share Posted March 26, 2020 Pretty cool for only 3 pages of RAM. 1 Quote Link to comment Share on other sites More sharing options...
xxl Posted March 26, 2020 Author Share Posted March 26, 2020 optimization - 70 bytes shorter. During initialization, the entire Menu structure is scanned and a dynamically generated table of keyboard shortcuts. this version is quite good now xmenu.xex 3 Quote Link to comment Share on other sites More sharing options...
xxl Posted March 27, 2020 Author Share Posted March 27, 2020 (edited) 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 March 27, 2020 by xxl 4 Quote Link to comment Share on other sites More sharing options...
+bob1200xl Posted March 27, 2020 Share Posted March 27, 2020 And where do I plug in my TK-II mouse? This would be great with mouse support! Bob Quote Link to comment Share on other sites More sharing options...
xxl Posted April 11, 2020 Author Share Posted April 11, 2020 (edited) 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 April 11, 2020 by xxl Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.