[A86] Re: TI-86 Menu Routine


[Prev][Next][Index][Thread]

[A86] Re: TI-86 Menu Routine




oops!, I'm sorry that stack representation got all messed up.

Here's another try:

Top:        000x
               eeee
               dddd
               cccc
               bbbb
               aaaa
               rrrr

x is the number of entries there are
eeee is the address of the text that will go in slot #5
dddd is the address of the text that will go in slot #4
cccc is the address of the text that will go in slot #3
bbbb is the address of the text that will go in slot #2
aaaa is the address of the text that will go in slot #1
rrrr is the address where the function will go when it is finished

-----------------------------------------
| Slot# | Slot# | Slot# | Slot# | Slot# |
|   1   |   2   |   3   |   4   |   5   |

Sorry,

Michael Williams

Michael Williams wrote:

>Hey All!
>    I finally got my menu routine working.  Here it is in case any of 
>y'all want to try it out.  All it does is output the menu bar and the 
>text you supply on the screen.  When you jump to Do_Menu (you have to 
>jump, otherwise this function will get really messed up), the stack must 
>look like this:
>
>Top:    000x           x is the number of entries there are
>           eeee           eeee is the address of the text that will go 
>in slot #5
>           dddd          dddd is the address of the text that will go in 
>slot #4
>           cccc           cccc is the address of the text that will go 
>in slot #3
>           bbbb          bbbb is the address of the text that will go in 
>slot #2
>           aaaa           aaaa is the address of the text that will go 
>in slot #1
>           rrrr             rrrr is the address where the function will 
>go when it is finished
>
>----------------------------------------------------------------------
>|    Slot#        |   Slot#         |   Slot#         |    Slot#        
>|     Slot#       |
>|       1           |       2           |       3           |      4    
>        |        5          |
>
>This function does not jump anywhere based on what keys the user 
>presses.  You must supply that loop.
>
>I hope y'all dont think I'm stupid for doing this, and if you guys find 
>any bugs, or have any suggestions, I'm always available at 
>spacex@williams-net.org.
>
>Thanks!
>Michael Williams
>
>#include "ti86asm.inc"
>
>.org _asm_exec_ram
>
>  call _clrScrn
>  ld hl,Post
>  push hl
>  ld hl,Text1
>  push hl
>  ld hl,Text2
>  push hl
>  ld hl,Text3
>  push hl
>  ld hl,Text4
>  push hl
>  ld hl,Text5
>  push hl
>  ld hl,$0005
>  push hl
>  jp Do_Menu
>Post:
>  call _getkey
>  ret
>
>Text1:
>.db "This",0
>Text2:
>.db "Finally",0
>Text3:
>.db "Does",0
>Text4:
>.db "Works",0
>Text5:
>.db "!!!!!!!",0
>
>
>Do_Menu:
>  call Do_Menu_Bar
>  pop bc
>  ld b,c
>Loop:
>  pop hl
>  call WriteText
>  djnz Loop
>  ret
>
>WriteText:
>  push bc
>  ld c,$03
>  ld a,b
>  cp $01
>  jp z,A1
>  cp $02
>  jp z,A2
>  cp $03
>  jp z,A3
>  cp $04
>  jp z,A4
>  cp $05
>  jp z,A5
>  ret
>
>A1:
>  ld a,c
>  jp Cont
>A2:
>  ld a,c
>  add a,$19
>  jp Cont
>A3:
>  ld a,c
>  add a,$32
>  jp Cont
>A4:
>  ld a,c
>  add a,$4B
>  jp Cont
>A5:
>  ld a,c
>  add a,$64
>  jp Cont
>Cont:
>  ld c,a
>  ld b,$3A
>  call CutString
>  add a,0
>  rr a
>  add a,c
>  ld c,a
>  ld (_penCol),bc
>  call _vputs
>  pop bc
>  ret
> 
>
>CutString:
>  push hl
>  push bc
>  dec hl
>  ld b,$00
>  ld c,$15
>CS_Loop:
>  inc hl
>  ld a,(hl)
>  cp $00
>  jp z,CutNow
>  cp $01
>  jp z,Minus5
>  cp $02
>  jp z,Minus5
>  cp $03
>  jp z,Minus5
>  cp $04
>  jp z,Minus5
>  cp $05
>  jp z,Minus4
>  cp $06
>  jp z,Minus5
>  cp $07
>  jp z,Minus5
>  cp $08
>  jp z,Minus4
>  cp $09
>  jp z,Minus4
>  cp $0A
>  jp z,Minus5
>  cp $0B
>  jp z,Minus5
>  cp $0C
>  jp z,Minus5
>  cp $0D
>  jp z,Minus5
>  cp $0E
>  jp z,Minus5
>  cp $0F
>  jp z,Minus5
>  cp $10
>  jp z,Minus4
>  cp $11
>  jp z,Minus5
>  cp $12
>  jp z,Minus4
>  cp $13
>  jp z,Minus4
>  cp $14
>  jp z,Minus5
>  cp $15
>  jp z,Minus5
>  cp $16
>  jp z,Minus4
>  cp $17
>  jp z,Minus5
>  cp $18
>  jp z,Minus6
>  cp $19
>  jp z,Minus5
>  cp $1A
>  jp z,Minus3
>  cp $1B
>  jp z,Minus4
>  cp $1C
>  jp Z,Minus5
>  cp $1D
>  jp z,Minus6
>  cp $1E
>  jp z,Minus4
>  cp $1F
>  jp z,Minus4
>  cp $20
>  jp z,Minus1
>  cp $21
>  jp z,Minus2
>  cp $22
>  jp z,Minus4
>  cp $23
>  jp z,Minus6
>  cp $24
>  jp z,Minus6
>  cp $25
>  jp z,Minus4
>  cp $26
>  jp z,Minus5
>  cp $27
>  jp z,Minus2
>  cp $28
>  jp z,Minus3
>  cp $29
>  jp z,Minus3
>  cp $2A
>  jp z,Minus6
>  cp $2B
>  jp z,Minus4
>  cp $2C
>  jp z,Minus3
>  cp $2D
>  jp z,Minus4
>  cp $2E
>  jp z,Minus2
>  cp $2F
>  jp z,Minus4
>  cp $30
>  jp z,Minus4
>  cp $31
>  jp z,Minus4
>  cp $32
>  jp z,Minus4
>  cp $33
>  jp z,Minus4
>  cp $34
>  jp z,Minus4
>  cp $35
>  jp z,Minus4
>  cp $36
>  jp z,Minus4
>  cp $37
>  jp z,Minus4
>  cp $38
>  jp z,Minus4
>  cp $39
>  jp z,Minus4
>  cp $3A
>  jp z,Minus2
>  cp $3B
>  jp z,Minus3
>  cp $3C
>  jp z,Minus4
>  cp $3D
>  jp z,Minus4
>  cp $3E
>  jp z,Minus4
>  cp $3F
>  jp z,Minus4
>  cp $40
>  jp z,Minus5
>  cp $41
>  jp z,Minus4
>  cp $42
>  jp z,Minus4
>  cp $43
>  jp z,Minus4
>  cp $44
>  jp z,Minus4
>  cp $45
>  jp z,Minus4
>  cp $46
>  jp z,Minus4
>  cp $47
>  jp z,Minus5
>  cp $48
>  jp z,Minus4
>  cp $49
>  jp z,Minus2
>  cp $4A
>  jp z,Minus4
>  cp $4B
>  jp z,Minus5
>  cp $4C
>  jp z,Minus4
>  cp $4D
>  jp z,Minus6
>  cp $4E
>  jp z,Minus5
>  cp $4F
>  jp z,Minus4
>  cp $4F
>  jp z,Minus4
>  cp $50
>  jp z,Minus4
>  cp $51
>  jp z,Minus5
>  cp $52
>  jp z,Minus4
>  cp $53
>  jp z,Minus4
>  cp $54
>  jp z,Minus4
>  cp $55
>  jp z,Minus4
>  cp $56
>  jp z,Minus4
>  cp $57
>  jp z,Minus6
>  cp $58
>  jp z,Minus4
>  cp $59
>  jp z,Minus4
>  cp $5A
>  jp z,Minus4
>  cp $5B
>  jp z,Minus3
>  cp $5C
>  jp z,Minus4
>  cp $5D
>  jp z,Minus3
>  cp $5E
>  jp z,Minus4
>  cp $5F
>  jp z,Minus4
>  cp $60
>  jp z,Minus3
>  cp $61
>  jp z,Minus4
>  cp $62
>  jp z,Minus4
>  cp $63
>  jp z,Minus4
>  cp $64
>  jp z,Minus4
>  cp $65
>  jp z,Minus4
>  cp $66
>  jp z,Minus3
>  cp $67
>  jp z,Minus4
>  cp $68
>  jp z,Minus4
>  cp $69
>  jp z,Minus2
>  cp $6A
>  jp z,Minus4
>  cp $6B
>  jp z,Minus4
>  cp $6C
>  jp z,Minus3
>  cp $6D
>  jp Z,Minus6
>  cp $6E
>  jp z,Minus4
>  cp $6F
>  jp z,Minus4
>  cp $70
>  jp z,Minus4
>  cp $71
>  jp z,Minus4
>  cp $72
>  jp z,Minus4
>  cp $73
>  jp z,Minus3
>  cp $74
>  jp z,Minus3
>  cp $75
>  jp z,Minus4
>  cp $76
>  jp z,Minus4
>  cp $77
>  jp z,Minus6
>  cp $78
>  jp z,Minus4
>  cp $79
>  jp z,Minus4
>  cp $7A
>  jp z,Minus4
>  cp $7B
>  jp z,Minus4
>  cp $7C
>  jp z,Minus2
>  cp $7D
>  jp Z,Minus4
>  cp $7E
>  jp z,Minus4
>  cp $7F
>  jp z,Minus4
>  cp $80
>  jp z,Minus4
>  cp $81
>  jp z,Minus3
>  cp $82
>  jp z,Minus4
>  cp $83
>  jp z,Minus4
>  cp $84
>  jp z,Minus4
>  cp $85
>  jp z,Minus4
>  cp $86
>  jp z,Minus4
>  cp $87
>  jp z,Minus4
>  cp $88
>  jp z,Minus4
>  cp $89
>  jp z,Minus4
>  cp $8A
>  jp z,Minus4
>  cp $8B
>  jp z,Minus4
>  cp $8C
>  jp z,Minus4
>  cp $8D
>  jp Z,Minus4
>  cp $8E
>  jp z,Minus4
>  cp $8F
>  jp z,Minus4
>  cp $90
>  jp z,Minus4
>  cp $91
>  jp z,Minus4
>  cp $92
>  jp z,Minus4
>  cp $93
>  jp z,Minus4
>  cp $94
>  jp z,Minus4
>  cp $95
>  jp z,Minus4
>  cp $96
>  jp z,Minus4
>  cp $97
>  jp z,Minus4
>  cp $98
>  jp z,Minus4
>  cp $99
>  jp z,Minus4
>  cp $9A
>  jp z,Minus2
>  cp $9B
>  jp z,Minus2
>  cp $9C
>  jp z,Minus2
>  cp $9D
>  jp Z,Minus2
>  cp $9E
>  jp z,Minus2
>  cp $9F
>  jp z,Minus2
>  cp $A0
>  jp z,Minus2
>  cp $A1
>  jp z,Minus2
>  cp $A2
>  jp z,Minus4
>  cp $A3
>  jp z,Minus4
>  cp $A4
>  jp z,Minus4
>  cp $A5
>  jp z,Minus4
>  cp $A6
>  jp z,Minus4
>  cp $A7
>  jp z,Minus4
>  cp $A8
>  jp z,Minus4
>  cp $A9
>  jp z,Minus4
>  cp $AA
>  jp z,Minus4
>  cp $AB
>  jp z,Minus4
>  cp $AC
>  jp z,Minus4
>  cp $AD
>  jp Z,Minus4
>  cp $AE
>  jp z,Minus4
>  cp $AF
>  jp z,Minus4
>  cp $B0
>  jp z,Minus4
>  cp $B1
>  jp z,Minus4
>  cp $B2
>  jp z,Minus4
>  cp $B3
>  jp z,Minus4
>  cp $B4
>  jp z,Minus5
>  cp $B5
>  jp z,Minus5
>  cp $B6
>  jp z,Minus3
>  cp $B7
>  jp z,Minus3
>  cp $B8
>  jp z,Minus4
>  cp $B9
>  jp z,Minus4
>  cp $BA
>  jp z,Minus2
>  cp $BB
>  jp z,Minus4
>  cp $BC
>  jp z,Minus4
>  cp $BD
>  jp Z,Minus4
>  cp $BE
>  jp z,Minus6
>  cp $BF
>  jp z,Minus4
>  cp $C0
>  jp z,Minus4
>  cp $C1
>  jp z,Minus4
>  cp $C2
>  jp z,Minus4
>  cp $C3
>  jp z,Minus5
>  cp $C4
>  jp z,Minus6
>  cp $C5
>  jp z,Minus4
>  cp $C6
>  jp z,Minus4
>  cp $C7
>  jp z,Minus4
>  cp $C8
>  jp z,Minus4
>  cp $C9
>  jp z,Minus6
>  cp $CA
>  jp z,Minus6
>  cp $CB
>  jp z,Minus4
>  cp $CC
>  jp z,Minus4
>  cp $CD
>  jp Z,Minus4
>  cp $CE
>  jp z,Minus6
>  cp $CF
>  jp z,Minus4
>  cp $D0
>  jp z,Minus3
>  cp $D1
>  jp z,Minus4
>  cp $D2
>  jp z,Minus3
>  cp $D3
>  jp z,Minus4
>  cp $D4
>  jp z,Minus4
>  cp $D5
>  jp z,Minus4
>  cp $D6
>  jp z,Minus4
>  jp CutNow
> 
>CutNow:
>  ld (hl),$00
>  ld a,c
>  pop bc
>  pop hl
>  ret
>
>Minus1:
>  ld a,c
>  ld b,$01
>  jp Minus
>
>Minus2:
>  ld a,c
>  ld b,$02
>  jp Minus
>
>Minus3:
>  ld a,c
>  ld b,$03
>  jp Minus
>
>Minus4:
>  ld a,c
>  ld b,$04
>  jp Minus
>
>Minus5:
>  ld a,c
>  ld b,$05
>  jp Minus
>
>Minus6:
>  ld a,c
>  ld b,$06
>  jp Minus
>
>Minus:
>  cp b
>  jp c,CutNow
>  sub b
>  ld b,$00
>  ld c,a
>  jp CS_Loop
>
>Do_Menu_Bar:
>  push hl
>  push de
>  ld a,%11111111
>  ld hl,$FF80
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  inc hl
>  ld (hl),a
>  ld de,$0010
>  ld a,%11111110
>  ld hl,$FF8f
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>
>  ld a,%00000000
>  ld hl,$FFA1
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFA2
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFA4
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFA5
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFA7
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFA8
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFAA
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFAB
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFAD
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld hl,$FFAE
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld a,%11000000
>  ld hl,$FFA0
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld a,%01100000
>  ld hl,$FFA3
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld a,%00110000
>  ld hl,$FFA6
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld a,%00011000
>  ld hl,$FFA9
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld a,%00001100
>  ld hl,$FFAC
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  ld a,%00000110
>  ld hl,$FFAF
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  add hl,de
>  ld (hl),a
>  pop de
>  pop hl
>  ret
>
>.end
>
>
>






References: