;Advanced Text Editer 1.0 ;by Jonah Cohen ;http://jonah.ticalc.org ;#define handle_errors ;NOTE: not working! ;#define custom_font ;#define grayscale #include "TI86.inc" .plugin lite86j .org _asm_exec_ram nop jp start .dw 0 .dw shell_title shell_title: .db "Advanced Text Editor 1.0",0 file_name: .db $12,1,0,0,0,0,0,0,0,0,0 exec_basic: call _PARSEINP in a,(5) cp $0d ld a,$0d out (5),a jp nz,_JforceCmdNoChar ;stop call _runIndicOff jr decompress ;in case code was recopied exec_asm: call _exec_assembly ex (sp),hl push af push hl decompress: ld a,(start+3) cp $cd ret z ;already decompressed ld hl,start+9002 ld de,$9000+8999 ld bc,9000 lddr inc hl inc de ex de,hl decompress_data: ld a,(hl) inc hl scf adc a,a .db $06 decompress_loop: add a,a jr z,decompress_data jr c,decompress_chunk ldi jr decompress_loop decompress_chunk: ld b,a ld c,$1f ld a,(hl) cp c jp z,refresh_data ;when we're done push bc inc hl ld b,(hl) inc hl push hl ld l,b ld b,a or c rlca rlca rlca ld h,a ld a,b and c add a,3 ld c,a ld b,0 add hl,de ldir pop hl pop af jr decompress_loop start: call decompress prog_start: #ifdef grayscale call remove_int #endif call _flushAllMenus call _runIndicOff call _clrWindow #ifdef handle_errors ;ld (stack_save),sp #endif call _OP6TOOP1 ld hl,_Flags+anumeditFlgs bit ex_asm_module,(hl) res ex_asm_module,(hl) jp nz,load_prog_edit ld hl,prog_start ld (progstart+1),hl ld hl,title ld de,$fc30 ld bc,title_end-title ldir ld b,3 title_loop: ld e,(hl) inc hl ld d,(hl) inc hl ld (_penCol),de call _vputs djnz title_loop ld hl,file_name rst 20h ld a,3 call check_file_validity ld a,2 jr nz,draw_main_menu inc a draw_main_menu: ld hl,main_menu ld (hl),a call draw_menu ld hl,edit_buffer+1 ld (edit_start),hl ld (edit_cursor),hl ld (edit_cursor2),hl call _RAM_PAGE_1 xor a ld (hl),a ;overwrite previous prog data ld (mode_flag),a ;lowercase alpha choose_option: call getkey cp K_EXIT jp z,exit sub K_F3 ld hl,(main_menu) dec l dec l ;check if count is 2 jr z,skip_f3 or a jp z,load_prog_edit skip_f3: dec a ;cp K_F2 jp z,load_prog dec a ;cp K_F1 jr nz,choose_option new_prog: ld (folder),a ;default folder ld hl,file_type ld a,(hl) sub 3 ;if all, reset to basic jr nz,$+3 ld (hl),a ld hl,new_text call disp_title call disp_mode ld a,4 ;stop before All call draw_file_types new_prog_restart: ld hl,browse_name+2 ld (hl),0 get_file_redraw: push hl ld b,6 call clear_file ld hl,browse_name+2 call _vputs pop hl get_file_name: call getkey_cursor jp z,prog_start ld de,file_type cp K_LEFT jr nz,not_filetype_left ld a,(de) dec a change_filetype_redraw: cp 3 jr c,do_filetype_redraw rlca add a,a and 3 do_filetype_redraw: ld (de),a push hl call redraw_file_types pop hl jr get_file_name not_filetype_left: cp K_RIGHT jr nz,not_filetype_right ld a,(de) inc a jr change_filetype_redraw not_filetype_right: cp K_ENTER jr z,get_file_selected cp K_CLEAR jr z,new_prog_restart cp K_DEL jr nz,get_file_not_del ld de,browse_name+2 call _cphlde jr z,get_file_name dec hl ld (hl),0 jr get_file_redraw get_file_not_del: push hl ld de,browse_name+2 call varname_char pop hl jr nz,get_file_name ld de,browse_name+10 call _cphlde jr nc,get_file_name ld (hl),a inc hl call _vputmap ld (hl),a jr get_file_name get_file_selected: ld de,browse_name+2 call _cphlde jr z,get_file_name ;nothing inputted ex de,hl call _strLength dec hl ld (hl),c ;store size dec hl rst 20h call check_file_name jp z,new_prog ;source file already exists jp nc,new_prog ;var already exists ld de,file_name call _MOVFROP1 ;store new file name call _RAM_PAGE_1 ld hl,(file_type) ld h,0 add hl,hl ld de,default_source_table add hl,de call $33 ld de,edit_buffer+1 copy_source: ld a,(hl) ld (de),a inc hl inc de cp $d6 jr nz,copy_source ld (edit_cursor),de ld hl,default_source ld bc,default_source_end-default_source ldir ex de,hl ld (edit_cursor2),hl ld (edit_end),hl ;set end jp first_edit draw_file_types: ld (max_file_type),a redraw_file_types: call backup_screen ld hl,$fd20 ld bc,112*256 clear_file_type: ld (hl),c inc hl djnz clear_file_type ld a,(file_type) inc a ld (selected_filetype),a ld hl,(_penCol) push hl ld h,18 ld a,(max_file_type) dec a ;if new menu, a=4 so we get 3 and 3 ;thus menu is shifted over 3 more add a,15 ld l,a ld (_penCol),hl ld hl,file_types xor a disp_new_file_types: cp 0 selected_filetype = $-1 jr nz,not_selected_filetype ld (iy+5),%1010 not_selected_filetype: push af call _vputs ld (iy+5),a call _VPUTBLANK call _VPUTBLANK pop af inc a cp 4 max_file_type = $-1 jr nz,disp_new_file_types ld hl,$231d ld (_penCol),hl ld hl,file_prompt call _vputs pop hl ld (_penCol),hl ld a,$7c out (0),a ret clear_files: ld b,29 clear_file: ;b=number of pixel rows to clear ld hl,$fe30 get_file_clear: ld de,8 add hl,de get_file_clear_line: ld (hl),d inc hl dec e jr nz,get_file_clear_line djnz get_file_clear ld hl,$2340 ld (_penCol),hl ret load_prog: ld hl,load_text call disp_title call disp_mode choose_file: ld a,5 ;include All call draw_file_types xor a ld (check_file_selected-1),a ld hl,default_search_name rst 20h ld de,file_names find_files: push de xor a call _findAlphaUp jr c,done_find_files call check_file pop de jr nz,find_files call _RAM_PAGE_1 ld hl,_OP1 ld bc,16 ldir ;add to table of files jr find_files done_find_files: pop hl ;hl=end of list ld de,file_names call _cphlde jr nz,not_no_source ;no source ld a,choose_file_loop-check_file_selected ld (check_file_selected-1),a call clear_files ld hl,not_found call _vputs jp choose_file_loop not_no_source: ld bc,-16 add hl,bc ld (file_end),hl ex de,hl ld (file_first),hl jr choose_file_redraw prev_file: ld de,file_names ld bc,-16 jr move_selector next_file: ld de,(file_end) ld bc,16 move_selector: call _cphlde jr z,choose_file_loop add hl,bc move_selector_check_scroll: push hl ex de,hl ld hl,(file_first) call _cphlde jr nc,$+3 ex de,hl ;min in de pop hl push hl ld bc,-48 add hl,bc call _cphlde jr nc,$+3 ex de,hl ;max in hl ld (file_first),hl pop hl choose_file_redraw: ld (file_selected),hl call backup_screen call clear_files call _RAM_PAGE_1 ld hl,0 file_first = $-2 display_file_names: push hl ld de,0 file_selected = $-2 call _cphlde jr nz,no_highlight_filename ld (iy+5),%1010 push hl rst 20h ;copy to OP1 pop hl no_highlight_filename: call _VPUTBLANK inc hl ld b,(hl) inc hl call _vputsn ld (iy+5),b ld hl,_penCol ld (hl),$40 inc hl ld a,(hl) add a,7 ld (hl),a pop hl cp 60 jr nc,choose_file_loop ld de,16 add hl,de ld de,0 file_end = $-2 inc de call _cphlde jr c,display_file_names choose_file_loop: ld a,$7c out (0),a call getkey cp K_EXIT jp z,prog_start cp K_LEFT jr nz,not_file_left ld b,-1 change_filetype: ld hl,file_type ld a,(hl) add a,b and 3 ld (hl),a jp choose_file not_file_left: ld b,1 cp K_RIGHT jr z,change_filetype jr check_file_selected ;self-modified check_file_selected: ld hl,(file_selected) cp K_DOWN jp z,next_file cp K_UP jp z,prev_file cp K_ENTER jr z,load_prog_edit cp K_SECOND jr z,load_prog_edit call get_alpha jr nz,choose_file_loop ld c,a ld hl,(file_selected) ld de,(file_end) ld b,2 scroll_file_choice: call _cphlde jr c,scroll_file_next ld hl,file_names ld de,(file_selected) djnz scroll_file_no_add ;restart at top jr choose_file_loop ;didn't find any scroll_file_next: push bc ld bc,16 add hl,bc pop bc scroll_file_no_add: inc hl \ inc hl ld a,(hl) ;get first letter of filename dec hl \ dec hl set 5,a cp c jp z,move_selector_check_scroll jr scroll_file_choice load_prog_edit: call check_file_name jp nc,exit call _clrLCD call load_op1 first_edit: xor a ld (edit_buffer),a inc a ld (dir),a #ifdef grayscale call install_int #endif call detect_f5_files edit_draw_menu: call draw_editor_menu edit: call _RAM_PAGE_1 call set_column edit_save_column: call backup_screen #ifdef grayscale ld (page),a ld a,5 ld (counter),a ld a,$06 ld (toggle),a #endif ld hl,$ff80 ld de,$ff7f ld bc,896 call _lddr inc c ;$0001 ld (_penCol),bc call check_cursors ld a,1 jr nz,text_selected ld de,edit_buffer+1 edit_start = $-2 call disp_chars jr finish_disp_screen text_selected: jr c,$+4 ex de,hl inc a push de ld de,(edit_start) call disp_chars push hl ld (iy+5),%00001010 ld hl,_penCol dec (hl) ld h,a call _VPUTBLANK ld a,h pop de pop hl call disp_chars ld (iy+5),0 finish_disp_screen: ex de,hl ld hl,edit_buffer+1 edit_end = $-2 call disp_chars ld hl,(edit_buffer+1) ld de,0 first_chars = $-2 call _cphlde ld (first_chars),hl call nz,draw_editor_menu ;if first 2 chars changed, redraw menu call disp_mode ;display mode ld a,$7c out (0),a #ifdef grayscale ld (page),a ld a,5 ld (counter),a ld a,$0c ld (toggle),a #endif ;ld hl,(edit_end) ;inc hl ;ld (hl),$d6 xor a ld (cursor_state),a wait_for_key: ;main key input routine jr alpha_notselected alpha_selected: halt ld a,%01011111 out (1),a nop \ nop in a,(1) rla jr nc,alpha_notselected ld a,alpha_notselected-alpha_selected ld (alpha_selected-1),a or a toggle_alpha_call: call toggle_alpha ;if cursor didn't move, switch mode alpha_notselected: jr second_notselected second_selected: halt ld a,%00111111 out (1),a nop \ nop in a,(1) and %00100000 jr z,second_notselected ld a,second_notselected-second_selected ld (second_selected-1),a toggle_second_call: call toggle_second ;if cursor didn't move, switch mode second_notselected: ld a,(alpha_selected-1) or a just_do_arrows: ld a,(cursor_state) jp z,do_arrows ld a,(second_selected-1) or a jr z,just_do_arrows call check_cursors jr nz,no_cursor call getkey_cursor2 jr got_key no_cursor: call getkey got_key: push af call get_char_no_mode pop bc jp z,insert_char ld a,b cp K_DEL jp z,delete cp K_CLEAR jp z,clear sub K_MORE jp z,paste inc a ;cp K_EXIT jp z,check_save inc a ;sub K_SECOND inc a ;sub K_F1-K_SECOND jp z,list inc a jp z,find inc a jp z,choose_char inc a jp z,save_prog inc a jp z,f5 do_arrows: or a call z,draw_cursor ld hl,alpha_selected-1 ld a,(hl) or a jr z,no_alpha_toggle ;already held down ld a,%01011111 out (1),a nop \ nop in a,(1) rla jr c,no_alpha_toggle ld (hl),0 ld hl,toggle_alpha_call ld (hl),$cd ;call no_alpha_toggle: ld hl,second_selected-1 ld a,(hl) or a jr z,no_second_toggle ;already held down ld a,%00111111 out (1),a nop \ nop in a,(1) and %00100000 jr nz,no_second_toggle ld (hl),a ld hl,toggle_second_call ld (hl),$cd ;call no_second_toggle: ld a,%01111110 out (1),a nop \ nop in a,(1) cpl and $0f jp z,wait_for_key ld hl,toggle_alpha_call ld (hl),$dc ld hl,toggle_second_call ld (hl),$dc ld b,0 get_arrow: rra inc b jr nc,get_arrow call check_cursors jr z,go_to_arrow ;one cursor ld a,(second_selected-1) cp 1 ccf jr nc,go_to_arrow ;nc if 2nd held call _cphlde jr c,go_to_arrow ex de,hl scf ;carry if cursors different go_to_arrow: dec b jp z,go_down dec b jr z,go_left dec b jr z,go_right go_up: jr nc,go_up2 ld (edit_cursor),hl call set_column call check_cursor go_up2: call bol ld a,(alpha_selected-1) or a jp z,page_up ld de,edit_buffer+1 call _cphlde jr nz,up_skip_search ;not first line set_cursor_edit: ld (edit_cursor),hl call check_cursor jp edit up_skip_search: dec hl call bol call add_row cursor_check_scroll: call check_cursor check_scroll: ld hl,(edit_cursor) ld de,(edit_start) call _cphlde jr nc,check_scroll_down call bol ;beginning of line cursor is on ld (edit_start),hl jp edit_save_column go_left: jr nc,left2 ld (edit_cursor),hl call set_column jr cursor_check_scroll left2: ld a,(alpha_selected-1) or a jp z,home ld de,edit_buffer+1 call _cphlde jp z,wait_for_key ;first character already ld de,(edit_start) call _cphlde dec hl jr nz,set_cursor_edit ;not off screen finish_left_right: ld (edit_cursor),hl call set_column jr cursor_check_scroll ;check cursor, scroll up go_right: dec de jr nc,$+3 ex de,hl ld a,(alpha_selected-1) or a jp z,end ld de,(edit_end) call _cphlde jp z,wait_for_key ;last character of program inc hl jr finish_left_right go_down: jr nc,go_down2 ex de,hl ld (edit_cursor),hl call set_column call check_cursor go_down2: ld a,(alpha_selected-1) or a jp z,page_down call eol dec hl ld (edit_cursor),hl ld de,(edit_end) call _cphlde push af call z,set_column ;last char pop af jr z,skip_add_row ;last char inc hl call add_row skip_add_row: call check_cursor check_scroll_down: ld hl,(edit_cursor) ld b,8 scroll_down_loop: push bc call bol pop bc ld de,(edit_start) call _cphlde jr c,no_scrolling ;edit_start is already lower dec hl djnz scroll_down_loop inc hl ld (edit_start),hl no_scrolling: jp edit_save_column home: call bol finish_home_end: jp set_cursor_edit end: call eol dec hl jr finish_home_end page_down: ld b,9 page_down_loop: push bc call eol pop bc djnz page_down_loop dec hl call bol finish_paging: call add_row ld (edit_cursor),hl jp cursor_check_scroll page_up: ld b,9 page_up_loop: call bol dec hl djnz page_up_loop done_page_up: inc hl jr finish_paging check_cursor: ld a,(second_selected-1) or a ret z ld hl,(edit_cursor) ld (edit_cursor2),hl ret check_cursors: ld hl,edit_buffer+1 edit_cursor = $-2 ld de,edit_buffer+1 edit_cursor2 = $-2 jp _cphlde add_row: push hl call eol pop de dec hl sbc hl,de ;carry=0 from eol jr z,next_char_closer ld a,0 column = $-1 ld b,l ;b=# of chars in row ld h,char_width_table/256 get_column: ex de,hl ld e,(hl) ex de,hl inc de ld c,a ;how close it is to previous char sub (hl) jr c,got_column ;past cursor djnz get_column ;at end of row xor a ;how close it is to next char got_column: neg ;how close it is to next char cp c jr c,next_char_closer dec de next_char_closer: ex de,hl ld (edit_cursor),hl ret set_column: ld hl,(edit_cursor) push hl call bol pop de xor a add_column: call _cphlde jr nz,continue_column ld (column),a ret continue_column: push hl ld l,(hl) ld h,char_width_table/256 add a,(hl) pop hl inc hl jr add_column paste: ld hl,clipboard call paste_hl jp check_scroll_down paste_hl: push hl call check_cursors call nz,del_hl_de ;delete selected string pop hl ld a,(hl) or a ret z ;no string push hl call _strLength ;bc=length of string ld hl,(edit_end) push hl add hl,bc ld de,edit_buffer+max_size call _cphlde jr nc,max_paste ex de,hl max_paste: ld (edit_end),de pop hl ;de=destination, hl=edit_end ld bc,(edit_cursor) push hl or a sbc hl,bc inc hl ex (sp),hl ;hl=edit_end, push size to copy pop bc lddr ex de,hl sbc hl,de ex (sp),hl ;clipboard pop bc ;size of clipboard ld de,(edit_cursor) push de jr z,$+4 ldir ex de,hl ld (edit_cursor),hl ;new cursor ld (edit_cursor2),hl call set_column ex (sp),hl ;get previous cursor call bol ;beginning of line previous cursor was on dec hl call bol ;line before it pop de ;end of pasted text jp insert_line_breaks_hl_de ;refresh all line breaks in pasted text save_prog: ld hl,file_name rst 20h ld hl,_OP1+1 ld c,(hl) ld b,0 add hl,bc inc hl ld (hl),b ;set null byte save_redraw: call clear_bottom ld hl,save_as call _vputs ld hl,_OP1+2 call _vputs dec hl save_getkey: call getkey_cursor jp z,edit_draw_menu cp K_ENTER jr z,save_selected cp K_CLEAR jr nz,save_not_clear xor a ld (_OP1+2),a jr save_redraw save_not_clear: cp K_DEL jr nz,save_not_del dec hl ld (hl),0 jr save_redraw save_not_del: push hl ld de,_OP1+2 call varname_char pop hl jr nz,save_getkey ld de,_OP1+10 call _cphlde jr nc,save_getkey ld (hl),a inc hl ld (hl),0 call _vputmap jr save_getkey save_selected: ld de,_OP1+2 call _cphlde jr z,save_getkey ;nothing entered push hl sbc hl,de ld a,l dec de ld (de),a ;size byte call check_file_name pop hl jr nc,save_getkey ;invalid call _RAM_PAGE_1 ld de,file_name call _MOVFROP1 call save_source call insert_line_breaks ;refresh line breaks call clear_bottom ld hl,saved draw_status: call _vputs call getkey jp edit_draw_menu list: ld a,(cursor_state) or a call nz,draw_cursor ;erase cursor xor a ld (selected_list_item),a ld hl,(file_type) ld h,a add hl,hl ld de,f1_table add hl,de call $33 ;hl->table of list items ld (list_table),hl redraw_list: call backup_screen call draw_rect ld hl,0 list_table = $-2 xor a ld de,$0912 new_list_item: ld (_penCol),de push af push de cp 0 selected_list_item = $-1 jr nz,not_selected ld (iy+5),%1010 not_selected: call _VPUTBLANK ld a,(hl) inc hl and 31 ld b,a disp_list_item: ld a,(hl) inc hl call _vputmap djnz disp_list_item ld (iy+5),b pop de ld a,e add a,34 ld e,a cp 100 jr c,not_new_list_line ld a,d add a,8 ld d,a ld e,$12 not_new_list_line: pop af inc a cp 15 jr nz,new_list_item ld a,$7c out (0),a get_list_choice: call getkey cp K_EXIT jp z,edit_save_column cp K_SECOND jr z,list_item_chosen cp K_ENTER jr z,list_item_chosen ld b,a ld a,(selected_list_item) ld d,3 dec b jr z,list_item_inc ld d,1 dec b jr z,list_item_dec dec b jr z,list_item_inc ld d,3 dec b jr nz,get_list_choice list_item_dec: sub d jr nc,set_list_item xor a set_list_item: ld (selected_list_item),a jr redraw_list list_item_inc: add a,d cp 15 jr c,set_list_item ld a,14 jr set_list_item list_item_chosen: ld hl,(list_table) ld d,0 ld a,(selected_list_item) ld b,a inc b jr get_next_list_item get_list_item: ld a,(hl) and 63 inc a ld e,a add hl,de get_next_list_item: djnz get_list_item ex de,hl ld a,(de) ld c,a and 63 ld b,a ld hl,insert_string ;create string here push hl copy_list_item: inc de ld a,(de) ld (hl),a inc hl djnz copy_list_item ld a,c ld b,' ' rla jr c,append_to_list ld b,'(' rla jr nc,no_append append_to_list: ld (hl),b inc hl no_append: ld (hl),0 pop hl call paste_hl ;insert string jp edit_save_column draw_rect: ld hl,$fc71 call draw_edge ld bc,41*256 rect_loop: push bc call list_clear_row pop bc djnz rect_loop draw_edge: ld c,-1 list_clear_row: set 0,(hl) ld b,12 level_clear_loop: inc hl ld (hl),c djnz level_clear_loop inc l set 7,(hl) inc l inc hl inc l ret find: call check_cursors jr z,find_new jr nc,$+3 ex de,hl or a sbc hl,de ld bc,12 push hl sbc hl,bc ex de,hl pop de ld b,c jr nc,$+3 ld b,e ld de,search_string copy_search_string: ld a,(hl) or a jr nz,$+4 ld a,' ' ld (de),a inc hl inc de djnz copy_search_string xor a ld (de),a find_new: call clear_bottom ld hl,search_prompt call _vputs ld hl,search_string call custm_vputs dec hl refresh_dir: call draw_dir find_input: call getkey_cursor jp z,edit_draw_menu cp K_ENTER jr z,find_selected cp K_CLEAR jr nz,find_not_clear xor a ld (search_string),a jr find_new find_not_clear: cp K_DEL jr nz,find_not_del dec hl ld (hl),0 jr find_new find_not_del: cp K_UP jr nz,find_not_up xor a ld (dir),a jr refresh_dir find_not_up cp K_DOWN jr nz,find_char ld (dir),a ;K_DOWN is already 1 :-) jr refresh_dir find_char: push hl call get_char pop hl jr nz,find_input ld de,search_string+12 call _cphlde jr z,find_input ;max length ld (hl),a inc hl ld (hl),0 call custm_vputmap jr find_input find_selected: ld a,(search_string) or a jr z,find_input ;nothing inputted call check_cursors jr c,$+3 ex de,hl ld a,0 dir = $-1 or a jr z,find_up find_down: inc hl ld de,(edit_end) call _cphlde jr nc,string_not_found push hl call check_hl pop hl jr find_down find_up: dec hl ld de,edit_buffer+1 call _cphlde jr c,string_not_found push hl call check_hl pop hl jr find_up string_not_found: call clear_bottom ld hl,str_not_found jp draw_status check_hl: ld de,search_string find_loop: ld a,(de) or a jr nz,find_not_done pop de ;remove call from stack ld (edit_cursor2),hl pop hl jp draw_menu_check_scrolling find_not_done: set 5,a ;lowercase ld b,a ld a,(hl) or a jr nz,$+4 ld a,' ' set 5,a ;lowercase cp b ret nz inc hl inc de push de ld de,(edit_end) inc de call _cphlde pop de jr c,find_loop or a ;nz ret draw_dir: ld a,(_penCol) push af ld a,$79 ld (_penCol),a ld a,(dir) add a,30 call _vputmap pop af ld (_penCol),a ret choose_char: #ifdef custom_font call clear_bottom #else ld hl,_plotSScreen+912 call clear_screen_bottom set textwrite,(iy+new_grf_flgs) #endif ld a,(first_char) ld c,a ld hl,char_table ld b,16 create_char_table: push bc ld (hl),c ld a,l add a,a add a,a add a,a add a,4 push hl ld l,(hl) ld h,char_width_table/256 ld b,(hl) pop hl srl b sub b ld (_penCol),a ld a,(hl) inc hl call custm_vputmap pop bc inc c ld a,c ;1-127 add a,a sbc a,a and 129 add a,c ld c,a djnz create_char_table #ifndef custom_font res textwrite,(iy+new_grf_flgs) ld hl,_plotSScreen+1023 ld de,$ffff ld bc,112 call _lddr inc de #else ld de,$fc00+912 #endif ld hl,(current_char) ld h,0 ;l=current char add hl,de ld bc,$07fe ld de,16 highlight_char: ld a,(hl) xor c ;flip all bits but 0 ld (hl),a add hl,de djnz highlight_char ld bc,32*256 current_char = $-2 first_char = $-1 choose_char_getkey: push bc call getkey pop bc cp K_EXIT jp z,edit_draw_menu dec a jr nz,not_down ld a,16 check_char: ;if b>127, b=b-127 add a,b ld b,a add a,a sbc a,a and 129 add a,b ld b,a save_char: ld (current_char),bc jp choose_char not_down: dec a jr nz,not_left dec c jp p,save_char scroll_left: inc c ld a,127-1 jr check_char not_left: dec a jr nz,not_right inc c ld a,16 cp c jr nz,save_char scroll_right: dec c ld a,1 jr check_char not_right: dec a jr nz,not_up ld a,127-16 jr check_char not_up: cp K_SECOND-4 jr z,char_selected cp K_ENTER-4 jr nz,choose_char_getkey char_selected: push bc call draw_editor_menu pop hl ld h,char_table/256 ld a,(hl) insert_char: push af ;save char ld b,0 cp $d6 jr nz,insert_abc ld a,(file_type) cp 2 jr nz,insert_abc ;not an asm file push bc call check_cursors call nz,del_hl_de ld hl,(edit_cursor) push hl call eol dec hl pop de pop bc call _cphlde ;only indent if cursor was at end of line jr nz,insert_abc dec hl ld a,(hl) cp ':' jr z,indent inc hl call bol ld a,(hl) cp ' ' jr nz,insert_abc indent: ld bc,' '*256 insert_abc: pop af ld hl,insert_string+2 ld (hl),c dec hl ld (hl),b dec hl ld (hl),a call paste_hl jp check_scroll_down check_save: ld hl,save_menu ld (hl),3 ld a,(file_type) or a jr nz,check_save_menu ld (hl),4 check_save_menu: call draw_menu check_save_getkey: call getkey cp K_EXIT jr z,progstart sub K_F4 jr nz,not_lock_prog lock_prog: ld a,(file_type) dec a jr nz,check_save_getkey ld hl,(edit_end) inc hl ld (edit_end),hl push hl ld de,edit_buffer sbc hl,de ex (sp),hl pop bc ld d,h ld e,l dec hl lddr inc a ;save not_lock_prog: dec a ;F3 jr nz,not_save_exit save_exit call save_source progstart: jp exit not_save_exit: dec a ;F2 jr z,progstart dec a ;F1 jp z,edit_draw_menu jr check_save_getkey cut_hl_de: ;copy code between hl and de to clipboard and remove from edit_buffer xor a .db 1 ;ld bc,xxxx del_hl_de: ;remove code between hl and de from edit_buffer ld a,skip_cut-do_cut ld (do_cut-1),a get_code_size: push hl or a sbc hl,de push af push de ld de,$f600-clipboard ;max space in clipboard call _cphlde jr c,max_clipboard ex de,hl max_clipboard: ex (sp),hl pop bc pop af pop de jr c,get_code_size ;wrong order ld (edit_cursor),hl ld (edit_cursor2),hl push hl jr do_cut do_cut: ld de,clipboard jr z,no_cut copy_to_clipboard: ld a,(hl) or a jr nz,$+4 ld a,' ' ld (de),a inc de cpi ;doesn't affect carry jp pe,copy_to_clipboard no_cut: ex de,hl ld (hl),c skip_cut: ld hl,(edit_end) sbc hl,de ;size to copy push de ex (sp),hl pop bc pop de jr z,no_del_copy ldir no_del_copy: ld (edit_end),de ;new end call check_cursors jr c,got_del_cursor ex de,hl got_del_cursor: ld (edit_cursor),hl ld (edit_cursor2),hl ld hl,(edit_start) del_check: dec hl ld de,(edit_cursor) call _cphlde jp c,refresh_current_line_breaks ;done call bol ld (edit_start),hl ;scroll up jr del_check delete: call check_cursors jr nz,do_delete ld hl,edit_buffer+1 call _cphlde jr z,edit2 ld h,d ld l,e dec de ;cut one letter do_delete: call cut_hl_de jr edit2 clear: call check_cursors jr nz,do_delete push hl ld a,$d6 cp (hl) jr z,clear_row ld de,(edit_end) call _cphlde jr z,clear_row call eol dec hl jr do_clear clear_row: dec hl call bol do_clear: pop de call cut_hl_de edit2: jp edit detect_f5_files: ld hl,zac_present ld (hl),$20 push hl ld hl,zac-1 rst 20h rst 10h pop hl jr c,check_text_view ld (hl),$28 check_text_view: ld hl,text_view_present ld (hl),$20 push hl ld hl,textview-1 rst 20h rst 10h pop hl ret c ld (hl),$28 ret f5: jr can_run_f5 check_f5 = $-1 can_run_f5: call save_source ;save source res 4,(iy+9) ld hl,file_name rst 20h call _OP1TOOP6 ld hl,(progstart+1) push hl ld hl,(edit_start) push hl ld hl,(edit_cursor) push hl ld hl,(edit_cursor2) push hl ld a,(mode_flag) push af ld a,0 file_type = $-1 or a jr nz,not_exec_basic call _clrWindow ld hl,_Flags+NewDispf ld a,(hl) set ProgramExecuting,(hl) push af push hl call exec_basic pop hl pop af ld (hl),a ld b,0 jr done_exec not_exec_basic: ld hl,textview-1 dec a jr z,call_prog ld hl,zac-1 call_prog: rst 20h set ex_asm_module,(iy+anumeditFlgs) ;module execution (uses OP6) #ifdef grayscale call remove_int #endif call exec_asm pop bc pop de done_exec: pop af ld (mode_flag),a pop hl ld (edit_cursor2),hl pop hl ld (edit_cursor),hl pop hl ld (edit_start),hl pop hl ld (progstart+1),hl ld a,b or a jr nz,error ld hl,file_name rst 20h jp load_prog_edit error: push de #ifdef grayscale call install_int #endif call load_op1 call detect_f5_files call _RAM_PAGE_1 ;call _POPREALO2 pop de ld hl,edit_buffer+1 ld a,(hl) cp 'A' jr z,skip_dec_de ;Zac returns line numbers off by 1 in includes search_for_line: dec de skip_dec_de: ld a,d or e jr nz,search_not_done ld (edit_cursor2),hl draw_menu_check_scrolling: ld (edit_cursor),hl call draw_editor_menu call set_column jp check_scroll search_not_done: ld a,$d6 ld bc,-1 cpir jr search_for_line custm_vputs: ld a,(hl) inc hl or a ret z cp $d6 jr nz,$+4 ld a,$5c call custm_vputmap jr custm_vputs disp_chars: push af push de push hl ld hl,_penRow ld a,(hl) cp 50 jr nc,no_prespace ;off screen already dec hl ld a,(hl) dec a ;check if we're at the beginning of a new line jr nz,no_prespace ld (hl),a ld h,(iy+5) set 1,(iy+5) ;underline call _VPUTBLANK ;display a leading space ld (iy+5),h ;reset display no_prespace: pop hl pop de pop af or a push af scf sbc hl,de ld b,h ld c,l ex de,hl jr c,done_disp_chars inc bc ld a,(_penRow) cp 50 jr nc,done_disp_chars ;finished disp_char_loop: ld a,(hl) cp $d6 jr z,new_line or a jr nz,not_new_line new_line: call _VPUTBLANK ex de,hl ld hl,_penRow ld a,(hl) add a,7 ld (hl),a dec hl ld (hl),1 ex de,hl cp 50 jr nc,done_disp_chars ;off screen bit 3,(iy+5) jr z,inc_char xor a ld (de),a ld a,' ' not_new_line: call custm_vputmap ;display character inc_char: cpi jp pe,disp_char_loop done_disp_chars: pop af dec a save_cursor: ret nz ex de,hl ld hl,(_penCol) dec l ld (cursor_col),hl ex de,hl ret #ifdef custom_font vputmap: jp _vputmap custm_vputmap: cp ' ' jr c,vputmap cp 128 jr nc,vputmap cp '#' jr z,vputmap cp '*' jr z,vputmap push hl ld hl,char_bitmap+1 ld (char_start),hl dec hl ld b,8 clear_bitmap: ld (hl),0 inc hl djnz clear_bitmap ld hl,shift_down ld bc,5 cpir jr nz,no_shift ld hl,char_bitmap+2 ld (char_start),hl no_shift: sub 32 ld l,a ld a,$b7 ;or a ld (shift),a srl l jr nc,no_rld ld a,$37 ;scf ld (shift),a no_rld: ld h,0 ld a,l add a,a add a,a rl h add a,l ld l,a ld a,0 adc a,h ld h,a ;multiply by 5 ld de,FontStart add hl,de ld de,char_bitmap char_start = $-2 ld bc,5 ldir ld d,c ld hl,char_bitmap-1 ld bc,7*256+%11110000 bit 3,(iy+5) jr z,shift_loop ld d,c ;inverted text shift_loop: inc hl shift: or a jr nc,skip_rld xor a rld skip_rld: ld a,(hl) and c xor d ld (hl),a djnz shift_loop ;char_bitmap contains our char ld ix,char_bitmap ld hl,(_penCol) ld b,l ld c,h ;putsprite ld h,$fc>>2 ld a,c add a,a add a,a ld l,a ld a,b rra add hl,hl rra add hl,hl rra or l ld l,a ld a,b and 7 ld (putspritex-1),a ld bc,$0700 putspritel: ex de,hl ld l,(ix) ld h,c inc ix jr putspritex putspritex: add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl ex de,hl ld a,d or (hl) ld (hl),a inc hl ld a,e or (hl) ld (hl),a ld de,15 add hl,de djnz putspritel ld hl,_penCol ld a,(hl) add a,4 ld (hl),a pop hl ret #else custm_vputmap: cp ' ' vputmap: jp nz,_vputmap bit 3,(iy+5) jr nz,vputmap push hl ld hl,_penCol inc (hl) pop hl ret #endif draw_cursor: ld hl,(_penCol) push hl ld hl,0 cursor_col = $-2 cursor_row = $-1 ld (_penCol),hl ld a,0 cursor_state = $-1 xor 8 ld (cursor_state),a or 2 ld hl,_Flags+textFlags ld (hl),a call _VPUTBLANK ld (hl),a pop hl ld (_penCol),hl ret getkey_cursor: ;removes cursor after a key is pressed push hl ld hl,(_penCol) ld (cursor_col),hl call getkey_cursor2 clear_cursor: ;push something and call this to remove cursor push af ld a,(cursor_state) or a call nz,draw_cursor pop af pop hl cp K_EXIT ret getkey: ld a,$b7 ;or a ld (cursor_toggle),a jr getkey_loop getkey_cursor2: ;leaves cursor ld a,$37 ;scf ld (cursor_toggle),a getkey_loop: xor a ld (cursor_state),a ;always show the cursor when you move ld c,200 ;apd countdown cursor_loop: push bc cursor_toggle: or a call c,draw_cursor pop bc ld b,60 ;cursor speed getkey_wait: xor a call _getcsc or a ret nz in a,(3) bit 3,a jr z,shut_down halt djnz getkey_wait dec c jr nz,cursor_loop shut_down: ld a,1 out (3),a halt ld a,11 out (3),a release_on: halt in a,(3) bit 3,a jr z,release_on jr getkey_loop get_char: cp K_SECOND jr z,toggle_second cp K_ALPHA jr z,toggle_alpha get_char_no_mode: cp K_PRGM jr nz,not_prgm ld hl,prgm_keys jr prgm_custm_sign not_prgm: cp K_CUSTOM jr nz,not_custm ld hl,custm_keys jr prgm_custm_sign not_custm: cp K_SIGN jr nz,not_sign ld hl,sign_keys prgm_custm_sign: ld a,0 mode_flag = $-1 rra ld e,a ld d,0 add hl,de ld a,(hl) cp a ret not_sign: ld hl,standard_keys push hl ld bc,5 cpir pop hl jr nz,not_normal_key add hl,bc ld a,(file_type) inc a ld c,a add a,a add a,a add a,c ld c,a add hl,bc ld a,(hl) cp a ret not_normal_key: ld hl,mode_flag bit 1,(hl) jr nz,special_char get_alpha: ld hl,letters ld bc,26 cpir ret nz ld a,'a' add a,c ld hl,mode_flag dec (hl) inc (hl) ret z res 5,a cp a ret special_char: ld hl,key_table1 ld bc,key_table2-key_table1 cpir ret nz ld hl,key_table2 add hl,bc ld a,(hl) cp a ret toggle_second: ld hl,mode_flag ld a,2 jr save_flag toggle_alpha: ld hl,mode_flag bit 1,(hl) jr nz,toggle_second ld a,1 save_flag: xor (hl) ld (hl),a disp_mode: ld a,(mode_flag) ld l,a ld h,0 ld de,mode_table add hl,de ld a,(hl) ld hl,$1400 ld (_curRow),hl call _putc nz: or 1 ret varname_char: cp K_SECOND jr z,toggle_second cp K_ALPHA jr z,toggle_alpha ld b,a ld a,(mode_flag) bit 1,a ld a,b jr z,get_alpha call _cphlde jr z,nz get_num: ld hl,num_table ld bc,10 cpir ret nz ld a,c add a,'0' cp a ret clear_bottom: ld hl,$fc00+912 clear_screen_bottom: ld b,112 xor a clear_bottom_loop: ld (hl),a inc hl djnz clear_bottom_loop ld hl,$3901 ld (_penCol),hl call clear_cursor ;pops call off stack anyway :-) save_source: ld hl,file_name rst 20h rst 10h call nc,_delvar call _RAM_PAGE_1 ld hl,(edit_end) push hl ld de,edit_buffer+1 xor a strip_spaces: ld bc,-1 cpdr call _cphlde jr c,done_strip_spaces inc hl ld (hl),' ' dec hl jr strip_spaces done_strip_spaces: pop hl ;retrieve edit_end or a dec de sbc hl,de ;hl=size call _CREATEPROG push hl dec hl dec hl dec hl dec hl ld (hl),0 ;set folder folder = $-1 pop hl call _DATA_SIZE_TO_DE call _SET_ABS_DEST_ADDR ld a,1 ld hl,edit_buffer-$8000 call _SET_ABS_SRC_ADDR xor a ex de,hl call _MM_LDIR_SET_SIZE call _RAM_PAGE_1 ld hl,edit_buffer+1 ld a,(hl) or a jr nz,save_file_name ex de,hl ld hl,(edit_end) scf sbc hl,de jr z,save_file_name push de ex (sp),hl pop bc inc hl ldir ld (edit_end),de save_file_name: ld hl,_asapvar rst 20h rst 10h xor a ld hl,file_name-_asm_exec_ram+4 ;offset add hl,de adc a,b call _SET_ABS_DEST_ADDR xor a ld hl,file_name call _SET_ABS_SRC_ADDR ld hl,11 call _MM_LDIR_SET_SIZE jp _RAM_PAGE_1 load_op1: ld de,file_name call _MOVFROP1 ;selected prog is in OP1 rst 10h call _DATA_SIZE_TO_DE call _GET_DATA_SIZE_DE_INC ld a,e or a jr nz,detok ld a,d or a jr nz,no_detok detok: push de call _setupEditequ pop de ld hl,$298e or a sbc hl,de jr nz,not_locked_tokenized ;locked tokenized call _bufDelete call _bufDelete jr not_untok not_locked_tokenized: ld a,d or e jr nz,not_untok ;locked untokenized call _bufDelete jr done_detok not_untok: call _detok call _bufToTop xor a call _bufInsert done_detok: call _closeEditequ no_detok: rst 10h push hl dec hl dec hl dec hl dec hl ld a,(hl) ld (folder),a ;save folder pop hl call _DATA_SIZE_TO_DE call _SET_ABS_SRC_ADDR ld hl,edit_buffer add hl,de ld (edit_end),hl ;set end of buffer ld a,1 ld hl,edit_buffer-$8000 call _SET_ABS_DEST_ADDR xor a ex de,hl call _MM_LDIR_SET_SIZE call _RAM_PAGE_1 insert_line_breaks: ld hl,edit_buffer+1 ld de,(edit_end) insert_line_breaks_hl_de: ld (done_line_breaks),de insert_line_breaks_loop: call refresh_line_breaks push hl ld de,0 done_line_breaks = $-2 or a sbc hl,de pop hl jr c,insert_line_breaks_loop ret refresh_current_line_breaks: ld hl,(edit_cursor) call bol push hl dec hl call bol call refresh_line_breaks pop de dec hl call _cphlde ret nc ex de,hl refresh_line_breaks: ld ix,0 ;ixh=length of line, ixl=done flag push hl ;hl->starting line to refresh ld hl,0 ld b,h ;flag for occurrence of $00 ld de,(edit_end) or a sbc hl,de ld (end_of_word),hl pop hl refresh_line_breaks_loop: push hl sll b ;so it's not 0 ;get new word ld c,0 ;word size in c ex de,hl next_letter: ld a,(de) or a jr nz,not_line_break ld b,a ;b=0 so we keep going ld a,' ' ld (de),a not_line_break: inc de ld h,char_width_table/256 ld l,a ld a,(hl) ;get width of char add a,c ;add to total cp width jr nc,word_too_long ;word is too long ld c,a ld a,l ;get char back ld hl,0 end_of_word = $-2 add hl,de jr c,no_more_lines ;end of document cp ' ' jr z,finish_word cp $d6 jr nz,next_letter ;stop if we hit end of line no_more_lines: ld ixl,1 ;not going any further finish_word: ex de,hl ;end of word pop de ld a,ixh add a,c ld ixh,a cp width jr nc,need_line_break ld a,ixl or a ;check if we're done jr z,refresh_line_breaks_loop ret need_line_break: ex de,hl dec hl ld (hl),0 ;space marked as line break inc hl dec b ;stop only if previous word had a break jr nz,refresh_line_breaks ret word_too_long: ;insert a space character ld a,c push de ld hl,(edit_end) ld de,edit_buffer+max_size call _cphlde jr c,$+3 ex de,hl pop de push hl dec de dec de dec de or a sbc hl,de ex (sp),hl pop bc ld d,h ld e,l inc hl ld (edit_end),hl ld (end_of_word),hl jr z,no_letters_to_shift ;values are the same ex de,hl lddr no_letters_to_shift: ld c,a xor a ld (de),a ;mark space as a line break inc de ld hl,(edit_cursor) call _cphlde jr c,finish_word inc hl ld (edit_cursor),hl call check_cursor jr finish_word exit: res 4,(iy+9) call save_file_name ;xor a ;ld (_asapvar+1),a ;force recopy jp _clrWindow bol: ;beginning of line ld de,edit_buffer+1 call _cphlde ex de,hl ret c ex de,hl ld d,$d6 bol_search: dec hl ld a,(hl) or a jr z,got_bol cp d jr nz,bol_search got_bol: inc hl ret eol: ;end of line ex de,hl ld hl,(edit_end) inc hl or a sbc hl,de ;maximum search ld b,h ld c,l ex de,hl ret z ld d,$d6 eol_search: ld e,(hl) ld a,d cpi ret z ret po ld a,e or a jr nz,eol_search ret disp_title: push hl call _clrLCD pop hl ld c,(hl) ;b already 0 inc hl ld (_penCol),bc call _vputs ld hl,$fc00 ld b,112 invert: ld a,(hl) cpl ld (hl),a inc hl djnz invert ret refresh_data: xor a ld (clipboard),a ld (search_string),a ;create width table ld hl,char_width_table ld (hl),1 ;space inc l create_char_loop: ld a,l #ifdef custom_font cp '#' jr z,normal_char cp '*' jr z,normal_char cp 32 jr c,normal_char cp 128 jr nc,normal_char ld b,4 jr got_width normal_char: #endif push hl call _copycharmaps ld b,(hl) pop hl got_width: ld (hl),b inc l jr nz,create_char_loop ret draw_menu: push hl ld de,$ffff ld b,0 call draw_bar_border ld a,5 draw_bar_loop: ld hl,bar_middle+15 call _lddr16 dec a jr nz,draw_bar_loop call draw_bar_border pop hl ld a,$39 ld (_penRow),a set 3,(iy+5) ld b,(hl) inc hl draw_menu_loop: ld a,(hl) ld (_penCol),a inc hl call _vputs djnz draw_menu_loop res 3,(iy+5) ret draw_bar_border: ld hl,bar_border+15 _lddr16: ld c,16 _lddr: ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ldd ret po jr _lddr backup_screen: ld hl,$ffff ld de,$f9ff ld bc,1024 call _lddr ld a,$76 out (0),a ret draw_editor_menu: xor a ld (check_f5),a ld a,2 ld (file_type),a ld hl,editor_menu call draw_menu call _RAM_PAGE_1 ld hl,57*256+108 ld (_penCol),hl ;for updating f5 ld hl,(edit_buffer+1) ld a,h cp ':' jr nz,basic_prog ld a,l cp 'A' jr z,disable_f5 cp 'Z' jr nz,not_asm_source ld hl,build zac_present: jr nz,disp_f5 disable_f5: ld a,edit2-can_run_f5+256 ld (check_f5),a ret not_asm_source: cp 'T' jr nz,basic_prog ;not text file ld a,1 ld (file_type),a ld hl,view text_view_present: jr nz,disp_f5 jr disable_f5 basic_prog: xor a ld (file_type),a ld hl,run disp_f5: set 3,(iy+5) call _vputs res 3,(iy+5) ret check_file: ld a,(file_type) check_file_validity: push af rst 10h call _DATA_SIZE_TO_DE push hl ld hl,max_size+3 or a sbc hl,de pop hl pop bc ret c ;invalid size call _GET_DATA_SIZE_DE_INC push hl ld hl,$288e call _cphlde pop hl jr z,invalid_file ld c,a ld a,b cp 3 ret z or a jr nz,check_not_basic check_basic: push bc push de push hl call check_asm pop hl pop de pop bc jr z,invalid_file call check_text toggle_z: jr z,invalid_file cp a ret invalid_file or 1 ret check_not_basic: dec a jr nz,check_asm check_text: ld a,e or a ret nz ld a,d cp 'T' ret nz jr check_colon check_asm: ld a,e or a ret nz ld a,d cp 'Z' jr z,check_colon cp 'A' ret nz check_colon: ld a,c call _GETB_AHL cp ':' ret check_file_name: ;checks file_name in op1 ;nc=invalid ;c=valid file ; z=source file ; nz=not source rst 10h inc b ;nz ret c ld a,(_OP1) cp $12 jr nz,invalid_file_name ld a,3 ;all datatypes call check_file_validity scf ret z ;a source file invalid_file_name: or a ret #ifdef handle_errors error_syntax = 135 error_undefined = 142 error_handler: ;push af ;call _popErrorHandler ;pop af ;cp error_syntax ;jr z,trap_error ;cp error_undefined ;jp nz,_monErrHand ;default error handler trap_error: push af call _runIndicOff ld hl,0 fpbase = $-2 ld (_FPBASE),hl ld hl,0 opbase = $-2 ld (_OPBASE),hl ld hl,basic_backup ld de,_PARSEVAR ld bc,_LASTENTRYPTR-_PARSEVAR ldir ld a,$0d out (5),a call _popErrorHandler pop af jp _monErrHand ;ld sp,0 ;stack_save = $-2 ;call _OP3TOOP1 ;jp load_prog_edit #if 0 ld hl,(_ELCNT) xor a call _dispHL call _newline ld hl, _OP3+2 ;name of basic program call _puts call _newline ld hl,(_P_CURPC+1) ld a,(_P_CURPC) call _dispHL call _newline jp _JforceCmdNoChar #endif #endif #ifdef grayscale int_start: ld hl,counter dec (hl) jr nz,no_reset ld (hl),5 jr flip_page no_reset: ld a,(hl) dec a ret nz flip_page: ld a,$3c page = $-1-int_start+_alt_interrupt_exec xor $0c toggle = $-1-int_start+_alt_interrupt_exec ld (page),a out (0),a ret counter = $-int_start+_alt_interrupt_exec .db 5 int_end: install_int: ld de,$f000 ld b,7 background_loop: push bc ld hl,background ld c,8 background_sprite_loop: ld a,(hl) inc hl ld b,16 background_row_loop: ld (de),a inc de djnz background_row_loop dec c jr nz,background_sprite_loop pop bc djnz background_loop ld h,d ld l,e inc de ld (hl),0 ld bc,127 ldir ld hl,int_start ld de,_alt_interrupt_exec push de ld bc,int_end-int_start ldir pop hl ld a,(hl) dec hl push hl ld de,40 ld b,5 checksum_loop: add hl,de add a,(hl) djnz checksum_loop pop hl ld (hl),a set 2,(iy+$23) ret remove_int: res 2,(iy+$23) ld a,$7c out (0),a ret #endif data_start: default_search_name: .db $12,1,0 title: .db $01,$FF,$FF,$FF,$FF,$FE,$00,$00,$FF,$FF,$80,$03,$FF,$F0,$00,$00 .db $00,$00,$00,$00,$00,$FE,$00,$7F,$FF,$FF,$80,$03,$FF,$E0,$00,$00 .db $00,$00,$00,$00,$01,$FE,$00,$01,$FF,$FF,$00,$7F,$FF,$E0,$00,$00 .db $00,$7F,$FF,$FF,$FF,$FE,$00,$00,$03,$E0,$00,$07,$C0,$00,$00,$00 .db $00,$00,$00,$03,$FF,$FE,$00,$00,$03,$C0,$00,$07,$80,$00,$00,$00 .db $00,$00,$00,$00,$03,$DE,$03,$FF,$FF,$C0,$00,$07,$80,$00,$00,$00 .db $00,$00,$00,$00,$07,$9F,$00,$00,$07,$C0,$00,$0F,$FF,$80,$00,$00 .db $00,$00,$00,$00,$0F,$0F,$00,$00,$0F,$80,$1F,$FF,$FF,$80,$00,$00 .db $00,$00,$FF,$FF,$FF,$0F,$00,$00,$7F,$80,$00,$0F,$FF,$80,$00,$00 .db $00,$00,$FF,$FF,$FE,$0F,$00,$00,$0F,$80,$00,$1F,$00,$00,$00,$00 .db $00,$00,$00,$00,$3E,$0F,$00,$00,$0F,$00,$00,$1F,$00,$00,$00,$00 .db $00,$00,$00,$00,$7F,$FF,$80,$00,$1F,$00,$00,$FE,$00,$00,$00,$00 .db $00,$00,$00,$00,$FF,$FF,$87,$83,$FF,$00,$F8,$3E,$00,$3F,$80,$00 .db $00,$00,$00,$00,$FC,$0F,$87,$80,$1E,$07,$F8,$3E,$00,$07,$80,$00 .db $00,$FF,$FF,$FF,$F0,$07,$87,$81,$FE,$00,$F8,$3F,$FF,$07,$80,$00 .db $00,$FF,$FF,$FF,$F0,$07,$8F,$80,$3E,$01,$F8,$7F,$FE,$0F,$80,$00 .db $00,$00,$00,$03,$E0,$07,$8F,$80,$3E,$07,$F8,$7F,$FE,$0F,$80,$00 title_end: .db 25,25,"Advanced Text Editor for",0 .db 16,32,"Basic, TextView, and Asm files",0 .db 39,42,"by Jonah Cohen",0 bar_border: .db %01111111,%11111111,%11111110,%00011111,%11111111,%11111111,%10000111,%11111111 .db %11111111,%11100001,%11111111,%11111111,%11111000,%01111111,%11111111,%11111110 bar_middle: .db %11111111,%11111111,%11111111,%00111111,%11111111,%11111111,%11001111,%11111111 .db %11111111,%11110011,%11111111,%11111111,%11111100,%11111111,%11111111,%11111111 #ifdef grayscale background: .db %10000011 .db %10000100 .db %01001000 .db %00111000 .db %00011100 .db %00010010 .db %00100001 .db %11000001 #endif main_menu: .db 3 .db 5,"NEW",0 .db 30,"OPEN",0 .db 56,"LAST",0 editor_menu: .db 4 .db 5,"LIST",0 .db 31,"FIND",0 .db 56,"CHAR",0 .db 82,"SAVE",0 run: .db " RUN",0 view: .db "VIEW ",0 build: .db "BUILD",0 save_menu: .db 4 .db 4,"BACK",0 .db 31,"QUIT",0 .db 56,"SAVE",0 .db 82,"LOCK",0 zac: .db 3,"Zac" textview: .db 8,"TextView" new_text: .db 49,"New file",0 file_prompt: .db "File name: ",0 load_text: .db 49,"Open file",0 save_as: .db "Save as: ",0 saved: .db "Saved",0 line_prompt: .db "Goto line number: ",0 search_prompt: .db "Search for: ",0 str_not_found: .db "Not found",0 not_found: .db "No files found",0 file_types: .db "File type:",0 .db " Basic",0 .db " Text",0 .db " Asm",0 .db " All",0 default_source_table: .dw basic_default_source .dw text_default_source .dw asm_default_source basic_default_source: .db "ClLCD",$d6 text_default_source: .db "T:Description",$d6 asm_default_source: .db "Z:Progname",$d6 default_source: .db "See F1 for built-in commands" default_source_end: f1_table: .dw basic_f1_list .dw text_f1_list .dw asm_f1_list ;format of list entries: ; bits 0-5: length of string ; bit 6: trailing ( ; bit 7: trailing space basic_f1_list: .db $84,"Disp" .db $05,"ClLCD" .db $82,"If" .db $85,"Input" .db $83,"Lbl" .db $43,"For" .db $86,"Prompt" .db $84,"Goto" .db $04,"Then" .db $45,"Outpt" .db $85,"Pause" .db $04,"Else" .db $44,"Menu" .db $04,"Stop" .db $03,"End" asm_f1_list: .db $88,"#include" .db $08,".db ",'"','"',",0" .db $84,".org" .db $83,".db" .db $83,".dw" .db $82,"ld" .db $84,"call" .db $84,"djnz" .db $82,"cp" .db $83,"inc" .db $83,"dec" .db $82,"ex" .db $82,"jr" .db $82,"jp" .db $03,"ret" text_f1_list: .db $02,"#B" .db $02,"#I" .db $02,"#U" .db $02,"#i" .db $02,"#C" .db $02,"#R" .db $02,"#S" .db $03,"#D0" .db $03,"#D1" .db $03,"#D2" .db $03,"#D3" .db $03,"#D4" .db $02,"#T" .db $01,LcapCCed .db $01,"~" letters: .db $19,$21,$0a,$12,$1a,$22,$0b,$13,$1b .db $23,$2b,$0c,$14,$1c,$24,$2c,$0d,$15 .db $1d,$25,$2d,$0e,$16,$1e,$26,$2e standard_keys: .db K_ENTER,K_GRAPH,K_TABLE,K_XVAR,K_STO basic_keys: .db Lstore,":)(",$d6 textview_keys: .db 178,":~#",$d6 asm_keys: .db '=',":;_",$d6 num_table: key_table1: .db K_9,K_8,K_7,K_6,K_5,K_4,K_3,K_2,K_1,K_0 .db K_DOT,K_LEFTPAR,K_RIGHTPAR,K_COMMA .db K_PLUS,K_MINUS,K_STAR,K_SLASH,K_EE ;these are letters A-F .db K_LN,K_RAISE,K_TAN,K_COS,K_SIN,K_LOG key_table2: .db "ABCDEF",Lpound,"/*-+",Lcomma,")(.0123456789" prgm_keys: .db Lquote,'$' custm_keys: .db Lapostrophe,'%' sign_keys: .db ' ',Lneg mode_table: .db 226,225,223,223 #ifdef custom_font shift_down: .db "gjpqy" #endif ;#include "font.asm" ;custom font .org ($+255)&$ff00 ;put on 256-byte boundary char_table: .org $+16 ;char menu characters browse_name: .org $+12 ;file name in new search_string: .org $+13 ;string to search for in find routine char_bitmap: .org $+20 ;bitmap for custom font insert_string: .org $+9 ;for inserting strings .org ($+255)&$ff00 ;put on 256-byte boundary char_width_table: .org $+256 ;width of all 256 chars #ifdef handle_errors basic_backup: .org $+256 ;pointers for basic programs (handle_errors) #endif clipboard: ;stuff that's cut file_names = $8100 ;files in open menu edit_buffer = $8100 ;open file text max_size = $bf00-edit_buffer ;max file size width = 121 ;max column for editing .end