home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / kshell.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  5.6 KB  |  192 lines

  1. #include "asm86.h"
  2. #include "ram86.inc"
  3. #include "Ti86abs.inc"
  4. #include "Ti86ops.inc"
  5. #include "Ti86asm.inc"
  6.  
  7. .org _asm_exec_ram
  8.  
  9. sub:
  10.  call $49DC
  11.  ld hl,$5a92                    ;has the name of (sqrt)KEY
  12.  rst 20h
  13.  rst 10h
  14.  jr c,Install
  15.  call _delvar                   ;if (sqrt)KEY exits, delete it
  16. Install:
  17.  ld hl,code_end-code+$60A       ;the name's still in OP1
  18.  push hl                        ;save the size
  19.  call _CREATEPROG               ;create a program the right size
  20.  ld a,b
  21.  ex de,hl
  22.  call $4c3f                     ;AHL+=2
  23.  call _SET_ABS_DEST_ADDR        ;here's where we want to copy to
  24.  xor a
  25.  pop hl                         ;restore the size
  26.  call _SET_MM_NUM_BYTES
  27.  ld hl,code                     ;a still = 0
  28.  call _SET_ABS_SRC_ADDR         ;here's the source
  29.  call _mm_ldir                  ;copy it!
  30.  set 6,(iy+$24)
  31.  jp $409C
  32. sub_end:
  33.  
  34. sub_size = (sub_end - sub + 2)
  35.  
  36. code:
  37. .db $8e,$28                     ;the ASM program header
  38.  call $479f            ;pop op1
  39.  ld hl,($c21c)                  ;the ptr to the ptr to the current menu + 4
  40.  dec hl \ dec hl
  41.  dec hl \ dec hl
  42.  call $4010                     ;ld hl,(hl)
  43.  ld de,$51f1                    ;the pointer to the program menu
  44.  call $403c                     ;see if they're the same
  45.  jr z,do_menu                   ;if so, do the menu
  46.  ld de,asm_table                ;see if we're at our homemade menu
  47.  call $403c
  48.  jp nz,the_end_abs              ;if not, then do normal exit
  49.  ld a,($d625)                   ;see if they're pushing F1-F5 on the
  50.  cp K_F1+1                      ;ASM menu and if not, then do normal exit
  51.  jp nc,the_end_abs
  52.  cp K_F5
  53.  jp c,the_end_abs
  54.  
  55.  ld b,4
  56.  ld de,paste_string
  57. paste_loop:
  58.  ld a,(de)
  59.  push bc
  60.  push de
  61.  call $5420
  62.  ld a,$0D
  63.  out (5),a
  64.  pop de
  65.  pop bc
  66.  inc de
  67.  djnz paste_loop
  68.  jp the_end_abs
  69.  
  70. do_menu:
  71.  ld hl,new_menu                 ;otherwise, make the pointer point to our
  72.  ld ($C210),hl
  73.  call $49C8                     ;display the menu (part 1)
  74.  call $49E8                     ;display the menu (part 2)
  75.  ld hl,basic_table+2            ;initialize the searching vars
  76.  ld (current_basic),hl
  77.  ld hl,asm_table+2
  78.  ld (current_asm),hl
  79.  ld hl,$0000
  80.  ld (counter_basic),hl
  81.  ld hl,copier_to                ;copy a standard menu into the ASM & BASIC
  82.  ld de,basic_table              ;submenus so if there aren't any programs
  83.  push hl                        ;of a type it still shows up right
  84.  call _mov10b
  85.  ld de,asm_table
  86.  pop hl
  87.  call _mov10b
  88.  ld hl,search_string            ;initialize what we're searching for
  89.  rst 20h
  90.  ld ix,prog_titles              ;point IX to where we're putting the names
  91. main_adding_loop:
  92.  xor a
  93.  call $514B                     ;get the next matching variable in the VAT
  94.  jr c,loop_end                  ;if carry set, no more vars, so end the loop
  95.  ld hl,_OP1+1                   ;point HL to the length and name
  96.  ld b,(hl)                      ;get the length
  97.  inc hl
  98.  ld (ix),$10                    ;load $10 into IX & increment - copy w/ space
  99.  push ix                        ;save IX, we need it later
  100.  inc ix
  101. adding_loop1:                   ;this copies the name of our found program 
  102.  ld a,(hl)                      ;out of OP1 and into our special memory area
  103.  ld (ix),a                      
  104.  inc hl
  105.  inc ix
  106.  djnz adding_loop1
  107.  ld (ix),$00                    ;puts zero at end of the name to terminate it
  108.  inc ix
  109.  rst 10h                        ;now it finds the variable
  110.  call $46AB                     ;checks if it is BASIC
  111.  jr nz,put_in_basic             ;if so, then it puts it in the BASIC thing
  112.  ld hl,(current_asm)
  113.  pop de                         ;the poped IX pointer we saved earlier is
  114.  ld (hl),e                      ;loaded into the menu table
  115.  inc hl
  116.  ld (hl),d
  117.  inc hl
  118.  ld (current_asm),hl
  119.  ld hl,counter_asm              ;our counter of ASM menu items is incremented
  120.  inc (hl)
  121.  jr main_adding_loop
  122. put_in_basic:
  123.  ld hl,(current_basic)
  124.  pop de                         ;the poped IX pointer we saved earlier is
  125.  ld (hl),e                      ;loaded into the menu table (but BASIC one)
  126.  inc hl
  127.  ld (hl),d
  128.  inc hl
  129.  ld (current_basic),hl
  130.  ld hl,counter_basic            ;our counter of BASIC menu items is increased
  131.  inc (hl)
  132.  jr main_adding_loop
  133. loop_end:
  134.  ld a,(counter_basic)           ;this loads the # of BASIC progs to the table
  135.  or a
  136.  jr z,skip_it1
  137.  ld (basic_table+1),a
  138. skip_it1:
  139.  ld a,(counter_asm)             ;this loads the # of ASM progs into the table
  140.  or a
  141.  jr z,skip_it2
  142.  ld (asm_table+1),a
  143. skip_it2:
  144. the_end:
  145. the_end_abs = $ - sub_size
  146.  ld a,($d625)
  147.  cp a
  148.  ret
  149.  
  150. paste_string = $ - sub_size
  151. .db "Asm("
  152.  
  153. search_string = $ - sub_size
  154. .db $12,0                       ;search for type $12 - a PRGM
  155.  
  156. new_menu = $ - sub_size         ;our new menu
  157. .db $09,$03                     ;new popup menu with 3 items
  158. .dw basic_entry                 ;our new BASIC list
  159. .dw asm_entry                   ;our new ASM list
  160. .dw $099d                       ;the old EDIT list
  161.  
  162. basic_entry = $ - sub_size
  163. .db $05                         ;?
  164. .dw basic_table                 ;point to our menu table
  165. .db "BASIC",0                   ;the title to appear
  166.  
  167. asm_entry = $ - sub_size
  168. .db $05                         ;?
  169. .dw asm_table                   ;point to our menu table
  170. .db "ASM",0                     ;the title to appear
  171.  
  172. copier_to = $ - sub_size
  173. .db $08,$01
  174. .dw copier_to+4
  175. ;copier_ptr = $ - code + $D746
  176. .db $10," ",0
  177.  
  178. code_end:
  179.  
  180. current_basic = $
  181. current_asm   = $ + $02
  182. counter_basic = $ + $04
  183. counter_asm   = $ + $05
  184.  
  185. basic_table   = $ + $06
  186. asm_table     = $ + $88
  187.  
  188. prog_titles   = $ + $10A
  189.  
  190. .end
  191.  
  192.