home *** CD-ROM | disk | FTP | other *** search
- #include "asm86.h"
- #include "ram86.inc"
- #include "Ti86abs.inc"
- #include "Ti86ops.inc"
- #include "Ti86asm.inc"
-
- .org _asm_exec_ram
-
- sub:
- call $49DC
- ld hl,$5a92 ;has the name of (sqrt)KEY
- rst 20h
- rst 10h
- jr c,Install
- call _delvar ;if (sqrt)KEY exits, delete it
- Install:
- ld hl,code_end-code+$60A ;the name's still in OP1
- push hl ;save the size
- call _CREATEPROG ;create a program the right size
- ld a,b
- ex de,hl
- call $4c3f ;AHL+=2
- call _SET_ABS_DEST_ADDR ;here's where we want to copy to
- xor a
- pop hl ;restore the size
- call _SET_MM_NUM_BYTES
- ld hl,code ;a still = 0
- call _SET_ABS_SRC_ADDR ;here's the source
- call _mm_ldir ;copy it!
- set 6,(iy+$24)
- jp $409C
- sub_end:
-
- sub_size = (sub_end - sub + 2)
-
- code:
- .db $8e,$28 ;the ASM program header
- call $479f ;pop op1
- ld hl,($c21c) ;the ptr to the ptr to the current menu + 4
- dec hl \ dec hl
- dec hl \ dec hl
- call $4010 ;ld hl,(hl)
- ld de,$51f1 ;the pointer to the program menu
- call $403c ;see if they're the same
- jr z,do_menu ;if so, do the menu
- ld de,asm_table ;see if we're at our homemade menu
- call $403c
- jp nz,the_end_abs ;if not, then do normal exit
- ld a,($d625) ;see if they're pushing F1-F5 on the
- cp K_F1+1 ;ASM menu and if not, then do normal exit
- jp nc,the_end_abs
- cp K_F5
- jp c,the_end_abs
-
- ld b,4
- ld de,paste_string
- paste_loop:
- ld a,(de)
- push bc
- push de
- call $5420
- ld a,$0D
- out (5),a
- pop de
- pop bc
- inc de
- djnz paste_loop
- jp the_end_abs
-
- do_menu:
- ld hl,new_menu ;otherwise, make the pointer point to our
- ld ($C210),hl
- call $49C8 ;display the menu (part 1)
- call $49E8 ;display the menu (part 2)
- ld hl,basic_table+2 ;initialize the searching vars
- ld (current_basic),hl
- ld hl,asm_table+2
- ld (current_asm),hl
- ld hl,$0000
- ld (counter_basic),hl
- ld hl,copier_to ;copy a standard menu into the ASM & BASIC
- ld de,basic_table ;submenus so if there aren't any programs
- push hl ;of a type it still shows up right
- call _mov10b
- ld de,asm_table
- pop hl
- call _mov10b
- ld hl,search_string ;initialize what we're searching for
- rst 20h
- ld ix,prog_titles ;point IX to where we're putting the names
- main_adding_loop:
- xor a
- call $514B ;get the next matching variable in the VAT
- jr c,loop_end ;if carry set, no more vars, so end the loop
- ld hl,_OP1+1 ;point HL to the length and name
- ld b,(hl) ;get the length
- inc hl
- ld (ix),$10 ;load $10 into IX & increment - copy w/ space
- push ix ;save IX, we need it later
- inc ix
- adding_loop1: ;this copies the name of our found program
- ld a,(hl) ;out of OP1 and into our special memory area
- ld (ix),a
- inc hl
- inc ix
- djnz adding_loop1
- ld (ix),$00 ;puts zero at end of the name to terminate it
- inc ix
- rst 10h ;now it finds the variable
- call $46AB ;checks if it is BASIC
- jr nz,put_in_basic ;if so, then it puts it in the BASIC thing
- ld hl,(current_asm)
- pop de ;the poped IX pointer we saved earlier is
- ld (hl),e ;loaded into the menu table
- inc hl
- ld (hl),d
- inc hl
- ld (current_asm),hl
- ld hl,counter_asm ;our counter of ASM menu items is incremented
- inc (hl)
- jr main_adding_loop
- put_in_basic:
- ld hl,(current_basic)
- pop de ;the poped IX pointer we saved earlier is
- ld (hl),e ;loaded into the menu table (but BASIC one)
- inc hl
- ld (hl),d
- inc hl
- ld (current_basic),hl
- ld hl,counter_basic ;our counter of BASIC menu items is increased
- inc (hl)
- jr main_adding_loop
- loop_end:
- ld a,(counter_basic) ;this loads the # of BASIC progs to the table
- or a
- jr z,skip_it1
- ld (basic_table+1),a
- skip_it1:
- ld a,(counter_asm) ;this loads the # of ASM progs into the table
- or a
- jr z,skip_it2
- ld (asm_table+1),a
- skip_it2:
- the_end:
- the_end_abs = $ - sub_size
- ld a,($d625)
- cp a
- ret
-
- paste_string = $ - sub_size
- .db "Asm("
-
- search_string = $ - sub_size
- .db $12,0 ;search for type $12 - a PRGM
-
- new_menu = $ - sub_size ;our new menu
- .db $09,$03 ;new popup menu with 3 items
- .dw basic_entry ;our new BASIC list
- .dw asm_entry ;our new ASM list
- .dw $099d ;the old EDIT list
-
- basic_entry = $ - sub_size
- .db $05 ;?
- .dw basic_table ;point to our menu table
- .db "BASIC",0 ;the title to appear
-
- asm_entry = $ - sub_size
- .db $05 ;?
- .dw asm_table ;point to our menu table
- .db "ASM",0 ;the title to appear
-
- copier_to = $ - sub_size
- .db $08,$01
- .dw copier_to+4
- ;copier_ptr = $ - code + $D746
- .db $10," ",0
-
- code_end:
-
- current_basic = $
- current_asm = $ + $02
- counter_basic = $ + $04
- counter_asm = $ + $05
-
- basic_table = $ + $06
- asm_table = $ + $88
-
- prog_titles = $ + $10A
-
- .end
-
-