Description Screenshots Documentation Bugs Download
Menu64 is a minimal set of functions to create simple text-oriented menus for the Commodore 64. The source is released under the LGPL v3, and written in 6502/6510 asm using 'ca65' (cross-assembler).
The test-program running in Vice:
The documentation mainly consists of comments in the source-code and an example test-program (64mnutst.asm).
To build the library, use:
cl65 -o 64mnutst.prg -t c64 -C c64-asm.cfg 64mnutst.asm
.
'c64-asm.cfg' standard uses $0801 as startaddress,
this should be equal to the address in your code.
The program stores data (menu-data) at address $cf00,
you can change this in the lines 36 and 37 of 64mnulib.asm
(mstartlo and mstarthi).
Aside from the cursor-keys, <clr/home> can be used to exit a
menu, you can change this in line 39 of 64mnulib.asm
(exitkey).
<Enter> or <Return> is used to confirm the contents of an edit-field.
Creating a menu starts with the definition of a menu, which looks like this:
mymenu:
.byt 18,13,10,5,"checkbox",0,0
.byt 1,14,10,6,"menu item",0,0
.byt 32,16,10,8,"an input item:",0,"some text",0,255
The format of an item is:
mode + type , id , xpos , ypos , caption , defaultvalue
The next step is to create a menu with jsr mcreate.
It starts with $fb and $fc pointing to
the menu-definition just created:
lda #<mymenu
sta $fb
lda #>mymenu
sta $fc
jsr _mcreate
rts
_mcreate copies the menu-data to mstartlo
, mstarthi and creates an index. $fb ,
$fc will be freed so they can be used as a pointer
to the active menu-item.
The next step is to draw the menu and call the eventhandler:
jsr _mdraw
jsr _mevent
rts
The last step is to add the activate function, which
is called inside the event-handler, _mevent. It is the
function where you can put the code that reacts to user-input.
The label-names in this example have the following format: 'ni' is an abbreviation for 'not item', followed by the item's id.
activate: ldy #$01
lda ($fb),y
cmp #00
bne ni00
ldy #$00
lda ($fb),y
and #$02
bne c1
lda #$00
sta $d020
jmp ni00
c1: lda $$0f
sta $d020
ni00: rts
This changes the border-color depending on the status of the
checkbox. Note that it checks the id first, and if
that is correct it will load the mode + type byte and
check bit 1 (and #$02).
Here is the entire code:
.org $c000 ; call with 'sys 49152'.
lda #<mymenu
sta $fb
lda #>mymenu
sta $fc
jsr _mcreate
jsr _mdraw
jsr _mevent
rts
activate: ldy #$01
lda ($fb),y
cmp #00
bne ni00
ldy #$00
lda ($fb),y
and #$02
bne c1
lda #$00
sta $d020
jmp ni00
c1: lda #$0f
sta $d020
ni00: rts
.include "64mnulib.asm"
mymenu:
.byt 18,13,10,5,"checkbox",0,0,
.byt 1,14,10,6,"menu item",0,0,
.byt 32,16,10,8,"an input item:",0,"some text",0,255
See menu64v01.html for documentation and more info about this version.