]> cloudbase.mooo.com Git - ddt180.git/blobdiff - ddt180.z80
Bugfix test_alphanum/test_numeral, command Q
[ddt180.git] / ddt180.z80
index f9a4014ec879b171d5eeba3262ed79abac590d82..122748d161aa820e17d27a33c012cfdf130fb5ef 100644 (file)
@@ -14,6 +14,7 @@ TPA   equ     0100h
        .phase  TPA\r
 \r
        jp      start\r
+       ds      3\r
 \r
 ldr_end:\r
 ldr_size       equ     $ - TPA\r
@@ -57,13 +58,17 @@ BDOS_SETDMA equ     26      ;Set DMA Address
 \r
 ; ddtz specific definitions\r
 \r
-STACK_SIZE     equ     64      ;ddtz internal stack\r
+STACK_SIZE     equ     80      ;ddtz internal stack\r
 CONBUF_SIZE    equ     80      ;Size of console input buffer\r
 EXPR_BUF_SIZE  equ     128     ;expressen buffer for conditional breakpoints\r
 BP_CNT         equ     12      ;Number of breakpoints\r
 BP_SIZE                equ     8       ;Size of a breakpoint record\r
 YREG_CNT       equ     10      ;Number of Y registers (0..9)\r
 \r
+SYMCASE_SENS   equ     0       ;Symbols are case sensitive\r
+SYMCASE_CONV   equ     1       ;Convert case when symbols are loaded\r
+SYMCASE_LOWER  equ     2       ;Convert to lower case if set, else to upper case\r
+\r
 ;-------------------------------------------------------------------------------\r
 \r
 ddtz_base:\r
@@ -75,6 +80,14 @@ sub_0004h:
        ret\r
 ddtz_bdos:\r
        jp      0\r
+screen_width:\r
+       db      80\r
+symlen_max:\r
+       db      16\r
+\r
+symattrib:\r
+       db      0\r
+\r
 \r
 current_cseg   defl    $ - current_cseg\r
        .phase  current_phase + current_cseg\r
@@ -122,7 +135,7 @@ reg.pc:     dw      TPA
 var.$: dw      0000h\r
 var.@: dw      0\r
 \r
-error_func:dw  l0146h\r
+error_func:dw  p_msg_error\r
 cmd_rpt:dw     mainloop\r
 \r
 conbuf:\r
@@ -199,7 +212,7 @@ CMDTAB:
 \r
 mainloop:\r
        ld sp,stack\r
-       ld hl,l0146h\r
+       ld hl,p_msg_error\r
        ld (error_func),hl\r
        ld hl,(reg.pc)\r
        ld (var.$),hl\r
@@ -236,7 +249,7 @@ exe_hl:
        call CALL_HL\r
        jr mainloop\r
 \r
-l0146h:\r
+p_msg_error:\r
        call    pstr_inl\r
        dc      '?'\r
        ;fall thru\r
@@ -434,7 +447,7 @@ p_align_@_sym:
        ld      a,d\r
        or      e\r
        pop     de\r
-       ld      a,(symlen_max)\r
+       ld      a,(symlen_cur)\r
        jr      z,$+4\r
        add     a,6\r
        add     a,c\r
@@ -450,6 +463,7 @@ p_goto_col:
 \r
 \r
 inchar:\r
+       push ix\r
        push hl\r
        push de\r
        push bc\r
@@ -464,6 +478,7 @@ l0284h:
        pop bc\r
        pop de\r
        pop hl\r
+       pop ix\r
        ret\r
 \r
 get_line:\r
@@ -489,10 +504,20 @@ toupper:
        cp 'a'\r
        ret c\r
        cp 'z'+1\r
-       ret nc\r
+       ccf\r
+       ret c\r
        and 05fh\r
        ret\r
 \r
+tolower:\r
+       cp 'A'\r
+       ret c\r
+       cp 'Z'+1\r
+       ccf\r
+       ret c\r
+       or 020h\r
+       ret\r
+\r
 skipbl0:\r
        inc de\r
 skipbl:\r
@@ -522,7 +547,7 @@ chk_stack:
        push de\r
        ld hl,0\r
        add hl,sp\r
-       ld de,stack-40\r
+       ld de,stack-(STACK_SIZE-28)\r
        call cp_hl_de\r
        pop de\r
        pop hl\r
@@ -1077,6 +1102,9 @@ do_factor:
        ld hl,(var.$)\r
        cp '$'\r
        ret z\r
+       ld hl,ddtz_base\r
+       cp 'Z'\r
+       ret z\r
        cp '-'\r
        jr z,fact_factneg\r
        cp '~'\r
@@ -1201,6 +1229,11 @@ error1:
 fact_symbol:\r
        push    bc\r
        ld      hl,ddtz_base            ;symtbl start\r
+       ld      a,(symattrib)\r
+       ld      c,07fh\r
+       rra\r
+       jr      c,fs_nxtsym\r
+       res     5,c\r
 \r
 fs_nxtsym:\r
        ld      a,(hl)                  ;symlen\r
@@ -1210,12 +1243,17 @@ fs_nxtsym:
        inc     b\r
        push    hl                      ;symtbl ptr\r
        push    de                      ;inpsym ptr\r
-fs_2:\r
+fs_nxtchar:\r
        ld      a,(de)\r
        djnz    fs_3\r
        call    test_sym_char\r
        jr      z,fs_cont\r
        pop     hl                      ;inpsym ptr (discard)\r
+       inc     de\r
+       cp      a,':'\r
+       jr      z,fs_cont_1\r
+       dec     de\r
+\r
        pop     hl                      ;symtbl ptr\r
        inc     hl\r
        ld      a,(hl)                  ;symval h\r
@@ -1225,13 +1263,16 @@ fs_2:
        or      a                       ;clear carry\r
        pop     bc\r
        ret\r
+\r
 fs_3:\r
        inc     de\r
        dec     hl\r
-       cp      (hl)\r
-       jr      z,fs_2\r
+       xor     (hl)\r
+       and     c\r
+       jr      z,fs_nxtchar\r
 fs_cont:                               ;start over\r
        pop     de                      ;inpsym ptr\r
+fs_cont_1:\r
        pop     hl                      ;symtbl ptr\r
        ld      a,(hl)\r
        add     a,3\r
@@ -1281,7 +1322,7 @@ l05dbh:
        jr next_bindigit\r
 l05e4h:\r
        cp '"'\r
-       jp nz,ERROR\r
+       jr nz,error11\r
        call get.bindigit\r
        jr nc,l05dbh\r
        or a\r
@@ -1306,6 +1347,7 @@ next_decdigit:
 decnum_done:\r
        cp '.'\r
        ret z\r
+error11:\r
        jp ERROR\r
 \r
 sub_060ch:\r
@@ -1506,17 +1548,35 @@ l0740h:
        call bp_enter\r
        jp user_go\r
 \r
+\r
+bpl_init:\r
+       ld      b,BP_CNT\r
+       ld      ix,bp_tab\r
+       ex      (sp),hl\r
+       ld      (pbl_loop_adr),hl\r
+       ex      (sp),hl\r
+       ret\r
+\r
+bpl_next:\r
+       ld      de,BP_SIZE\r
+       add     ix,de\r
+       dec     b\r
+       ret     z\r
+\r
+       ex      (sp),hl\r
+       ld      hl,(pbl_loop_adr)\r
+       ex      (sp),hl\r
+       ret\r
+\r
 bp_clr_temporary:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l075ah:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 0f1h\r
        ld (ix+000h),a\r
        call bp_clr_condition\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l075ah\r
+\r
+       call bpl_next\r
        ret\r
 \r
 cmd_B:\r
@@ -1543,9 +1603,8 @@ bp_clr_next:
 bp_clr_all:\r
        scf\r
 bp_clr:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l0799h:\r
+       call    bpl_init\r
+\r
        push af\r
        jr c,l07a7h\r
        ld e,(ix+002h)\r
@@ -1556,16 +1615,13 @@ l07a7h:
        ld (ix+000h),000h\r
        call bp_clr_condition\r
 l07aeh:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
        pop af\r
-       djnz l0799h\r
+       call bpl_next\r
        ret\r
 \r
 bp_print:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-bp_pr_l:\r
+       call    bpl_init\r
+\r
        bit 0,(ix+000h)\r
        jr z,bp_pr_cont\r
        ld a,'R'\r
@@ -1599,9 +1655,7 @@ l07cdh:
 l0805h:\r
        call crlf\r
 bp_pr_cont:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz bp_pr_l\r
+       call bpl_next\r
        ret\r
 \r
 ; Add break points to list\r
@@ -1619,7 +1673,7 @@ bp_enter:
 bp_e_1:\r
        push bc\r
        call expr\r
-       jp c,ERROR\r
+       jr c,error12\r
        pop bc\r
        bit 0,b\r
        push bc\r
@@ -1644,17 +1698,14 @@ bp_e_1:
        jr bp_enter\r
 \r
 bp_get_freeslot:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-bp_gf_l:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 00fh\r
        ret z\r
-       push bc\r
-       ld bc,BP_SIZE\r
-       add ix,bc\r
-       pop bc\r
-       djnz bp_gf_l\r
+\r
+       call    bpl_next\r
+error12\r
        jp ERROR\r
 \r
 bp_get_count:\r
@@ -1664,7 +1715,7 @@ bp_get_count:
        ret nz\r
        inc de\r
        call expr\r
-       jp c,ERROR\r
+       jr c,error12\r
        ret\r
 \r
 bp_get_condition:\r
@@ -1676,7 +1727,7 @@ bp_get_condition:
        call skipbl\r
        push de\r
        call expr\r
-       jp c,ERROR\r
+       jr c,error12\r
        ex de,hl\r
        pop de\r
        push de\r
@@ -1688,7 +1739,7 @@ bp_get_condition:
        add hl,bc\r
        ld de,expr_bufe\r
        call cp_hl_de\r
-       jp nc,ERROR\r
+       jr nc,error12\r
        pop hl\r
        ld (expr_p2),hl\r
        pop de\r
@@ -1756,9 +1807,8 @@ sub_0913h:
        ex af,af'\r
        sub a\r
        ld (l0941h),a\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l0920h:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 007h\r
        jr z,l0938h\r
@@ -1770,9 +1820,8 @@ l0920h:
        call z,sub_0942h\r
        pop bc\r
 l0938h:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l0920h\r
+\r
+       call    bpl_next\r
        ex af,af'\r
        ret\r
 \r
@@ -1810,9 +1859,8 @@ l0974h:
        ret\r
 \r
 sub_097ah:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l0980h:\r
+       call    bpl_init\r
+\r
        bit 5,(ix+000h)\r
        res 5,(ix+000h)\r
        jr z,l099ah\r
@@ -1825,15 +1873,13 @@ l0980h:
        ld (hl),a\r
 l099ah:\r
        res 3,(ix+000h)\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l0980h\r
+\r
+       call    bpl_next\r
        ret\r
 \r
 sub_09a6h:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l09ach:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 003h\r
        jr z,l09c0h\r
@@ -1843,9 +1889,8 @@ l09ach:
        call cp_hl_de\r
        ret z\r
 l09c0h:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l09ach\r
+\r
+       call    bpl_next\r
        sub a\r
        inc a\r
        ret\r
@@ -1862,15 +1907,14 @@ sub_09cah:
        and a\r
        ld a,008h\r
        jr nz,l09edh\r
-       ld a,004h\r
+       rra\r
 l09edh:\r
        ld (ix+000h),a\r
        ret\r
 \r
-sub_09f1h:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l09f7h:\r
+bp_set_to_mem:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and c\r
        jr z,l0a1dh\r
@@ -1891,9 +1935,8 @@ l09f7h:
        inc hl\r
        ld (hl),d\r
 l0a1dh:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l09f7h\r
+\r
+       call    bpl_next\r
        ret\r
 \r
 user_go:\r
@@ -1910,7 +1953,7 @@ user_go:
        call sub_1ffeh\r
        ld c,008h\r
 l0a41h:\r
-       call sub_09f1h\r
+       call bp_set_to_mem\r
        ld sp,reg.l2\r
        pop hl\r
        pop de\r
@@ -2443,7 +2486,7 @@ l0e5eh:
 p_sym_list:\r
        inc     de\r
        call    assert_eol\r
-       ld      a,(symlen_max)\r
+       ld      a,(symlen_cur)\r
        add     a,7\r
        ld      b,a\r
        ld      c,0\r
@@ -2467,7 +2510,7 @@ psym_nxtsym:
        ld      a,c\r
        add     b\r
        ld      c,a\r
-       ld      a,80                    ;screen width\r
+       ld      a,(screen_width)\r
        sub     b\r
        cp      c\r
        jr      nc,psym_nxtsym\r
@@ -2549,7 +2592,7 @@ sub_0ed7h:
        push    de\r
        push bc\r
 l0edah:\r
-       call get_char_upper\r
+       ld a,(de)\r
        cp (hl)\r
        jr nz,l0ee2h\r
        inc de\r
@@ -2800,6 +2843,7 @@ sub_1012h:
        cp '.'\r
        ret z\r
        ld c,'?'\r
+       call toupper\r
        cp '*'\r
        ret\r
 \r
@@ -3056,8 +3100,10 @@ read_symfile:
        call pstr_inl\r
        db      'SYMBOLS',CR,LF+80h\r
 \r
-       dec de\r
-       call file_open\r
+       dec     de\r
+       call    file_open\r
+       ld      a,(symattrib)\r
+       ld      c,a\r
 rs_1:\r
        call    read_byte\r
 rs_2:\r
@@ -3089,11 +3135,17 @@ rs_5:
        call    read_byte       ; next char of symbol name\r
        call    test_sym_char   ; valid char?\r
        jr      nz,rs_6\r
+       bit     SYMCASE_CONV,c\r
+       jr      z,rs_51\r
+       call    toupper\r
+       bit     SYMCASE_LOWER,c\r
+       call    nz,tolower\r
+rs_51:\r
        ld      (hl),a          ;\r
        inc     b               ; symlen++\r
-       ld      a,b             ;\r
-       cp      10h+1           ;\r
-       jr      c,rs_5          ;\r
+       ld      a,(symlen_max)  ;\r
+       cp      b               ;\r
+       jr      nc,rs_5         ;\r
 error3:\r
        jp      ERROR           ;\r
 \r
@@ -3126,14 +3178,15 @@ rs_61:
        ld      de,(BDOS+1)     ;\r
        ld      (BDOS+1),hl     ;\r
        ex      de,hl           ;\r
-       pop     af              ; symlen\r
-       ld      (hl),a          ;\r
+       pop     bc              ; symlen\r
+       ld      (hl),b          ;\r
        inc     hl              ;\r
        pop     de              ; symval\r
        ld      (hl),e          ;\r
        inc     hl              ;\r
        ld      (hl),d          ;\r
-       ld      hl,symlen_max   ;\r
+       ld      a,b             ;\r
+       ld      hl,symlen_cur   ;\r
        cp      (hl)            ; new max?\r
        jr      c,$+3           ;\r
        ld      (hl),a          ;\r
@@ -3163,18 +3216,21 @@ test_sym_char:
 ; return nc if valid alfanumeric char\r
 \r
 test_alphanum:\r
-       cp      'z'+1\r
+       cp      'z'\r
+       ret     z\r
        ccf\r
        ret     c\r
        cp      'a'\r
        ret     nc\r
-       cp      'Z'+1\r
+       cp      'Z'\r
+       ret     z\r
        ccf\r
        ret     c\r
        cp      '?'\r
        ret     nc\r
 test_numeral:\r
-       cp      '9'+1\r
+       cp      '9'\r
+       ret     z\r
        ccf\r
        ret     c\r
        cp      '0'\r
@@ -3311,7 +3367,7 @@ cmda_lpend:
        jr cmda_loop\r
 \r
 cmda_restart:\r
-       call l0146h\r
+       call p_msg_error\r
        ld sp,(l1262h)\r
        jr cmda_loop\r
 \r
@@ -5939,7 +5995,10 @@ disas_arg_16:
 disas_argtype:\r
        db      0\r
 \r
-symlen_max:            ;max length of symbols read so far\r
+pbl_loop_adr:\r
+       dw      0\r
+\r
+symlen_cur:            ;max length of symbols read so far\r
        db      0\r
 cur_fcb:\r
        dw      0\r