X-Git-Url: http://cloudbase.mooo.com/gitweb/ddt180.git/blobdiff_plain/dfd599a0a08f4aaabb0553c944eea38e82ef9da1..e800d6bed1ffbe37835710a9224d5adb63a0e97a:/ddt180.z80 diff --git a/ddt180.z80 b/ddt180.z80 index ef1dd6c..937faa6 100644 --- a/ddt180.z80 +++ b/ddt180.z80 @@ -35,8 +35,8 @@ bitmap_size equ (prog_size+7)/8 ;------------------------------------------------------------------------------- cseg -start:: -ddtz_base:: +start: +ddtz_base: jr reloc nop l0003h: @@ -54,6 +54,20 @@ signon: defvers dc ' (' +;------------------------------------------------------------------------------- + +reloc_getbit macro + local nextbit + exx + djnz nextbit + ld b,8 ;reload bit counter + ld e,(hl) ;get next 8 relocation bits + inc hl +nextbit: + sla e + exx + endm + ;------------------------------------------------------------------------------- ; Clear old position @@ -98,27 +112,49 @@ wearehere: ei ld hl,ddtz_end ;start of reloc bitmap add hl,de - push hl exx pop hl - ld bc,0108h ;init bit counter b (c==reload val) + ld b,1 ;init bit counter b exx LD HL,ddtz_base add hl,de ;--> ddtz_base - ld bc,prog_size + reloc_lp: - EXX - djnz reloc_nl - ld b,c ;reload bit counter - LD e,(HL) ;get next 8 relocation bits - INC HL -reloc_nl: - sla e - EXX - JR NC,reloc_next - DEC HL + push de + push hl + + ld de,4 + ld a,2 + ld hl,0 +reloc_l: + reloc_getbit + jr nc,reloc_got + cp 16 + jr z,reloc_done + add hl,de + ld b,a + ex de,hl +reloc_l1: + add hl,hl + djnz reloc_l1 + ex de,hl + add a,a + jr reloc_l +reloc_got: + ex de,hl + ld hl,0 + ld b,a +reloc_bitloop: + reloc_getbit + adc hl,hl + djnz reloc_bitloop + add hl,de + pop de + add hl,de + pop de + LD A,(HL) ADD A,E LD (HL),A @@ -126,17 +162,15 @@ reloc_nl: LD A,(HL) ADC A,D LD (HL),A -reloc_next: inc hl - dec bc - ld a,b - or c - jr nz,reloc_lp - + jr reloc_lp +reloc_done: + exx + ld (bitmap_end),hl ;------------------------------------------------------------------------------- -init:: +init: LD SP,stack if CPM @@ -181,8 +215,8 @@ ini_sign: call out_hl call pstr_inl dc ' - ' - ld de,prog_size+bitmap_size-1 - add hl,de + ld hl,(bitmap_end) + dec hl call out_hl call pstr_inl dc ')',CR,LF @@ -395,36 +429,78 @@ as1out: ;------------------------------------------------------------------------------- + +csio_rx_tmp: db 0ffh + csio_ista: + ld hl,csio_rx_tmp + ld a,(hl) + cp 0ffh + jr nz,csist_1 + ld a,01 + call csio_wr + call csio_rd + call csio_rd + ld (hl),a + sub a,0ffh + ret z +csist_1: + or 0ffh + ret + csio_inp: -csio_out: - xor a + ld hl,csio_rx_tmp + ld a,(hl) + ld (hl),0ffh + cp 0ffh + ret nz +csin_1: + ld a,01 + call csio_wr + call csio_rd + call csio_rd + cp 0ffh + jr z,csin_1 ret +csio_rd: + ld a,M_CSIO_RE + call csio_cmd_wait + in0 a,(trdr) + ret - ld a,0ffh -do_csio: - push af - call csio_wait_te - pop af +csio_out: + ld a,02 + call csio_wr + call csio_rd + call csio_rd + or a + jr z,csio_out + + ld a,c + inc a ;ff..02 --> 00..03 + cp 04h + jr nc,csout_1 + ld a,00h + call csio_wr +csout_1: + ld a,c +csio_wr: out0 (trdr),a ld a,M_CSIO_TE +csio_cmd_wait: out0 (cntr),a - call csio_wait_te - in0 a,(trdr) - ret - -csio_wait_te: +cswr_wait: in0 a,(cntr) - and M_CSIO_TE - jr nz,csio_wait_te + and M_CSIO_TE+M_CSIO_RE + jr nz,cswr_wait ret endif ; CPM ;------------------------------------------------------------------------------- -CMDTAB:: +CMDTAB: ; dw ERROR ;cmd_@ ;examine/substitute the displacement register @ ; dw ERROR ;cmd_A ;Assemble dw cmd_B ;Breakpoints display/set/clear @@ -457,7 +533,7 @@ ERROR: call pstr_inl dc '?',CR,LF ;fall thru -mainloop:: +mainloop: ld sp,stack ld hl,(reg.pc) call bp_clr_temporary @@ -478,7 +554,7 @@ mainloop:: inc de sub 'B' jr c,ERROR - cp 'Z'+1-'@' + cp 'Z'+1-'B' jr nc,ERROR ld hl,CMDTAB call add_hl_a2 @@ -1231,10 +1307,10 @@ fact_reg.CPU: inc hl ld h,(hl) ld l,a - and a + xor a ;clr cy, a=0 bit 0,c ret nz - ld h,000h + ld h,a ret fact_factinv: @@ -1549,7 +1625,14 @@ cmd_E: push af call get_arg_final - ld bc,prog_size+bitmap_size + ex de,hl + ld hl,(bitmap_end) + ld bc,ddtz_base + or a + sbc hl,bc + ld b,h + ld c,l + ex de,hl pop af jr nz,cmde_bottom sbc hl,bc @@ -1839,18 +1922,18 @@ bp_tst_@pc: call bpl_init ld a,(ix+000h) - and 003h - jr z,bp_tst_e + and 003h ;User bp (temporary or permanent)? + jr z,bp_tst_e ;No, check next ld e,(ix+002h) ld d,(ix+003h) ld hl,(reg.pc) - call cp_hl_de - ret z + call cp_hl_de ;Current PC is on a User bp + ret z ;Return zero bp_tst_e: call bpl_next sub a - inc a - ret + inc a ;Not on a user bp + ret ;Return not zero bp_trace_enter: call bp_get_freeslot @@ -1888,7 +1971,6 @@ bp_set_to_mem: inc hl ld (hl),d l0a1dh: - call bpl_next ret @@ -2593,12 +2675,14 @@ i.getchar: i.storebyte: push af push de - ld de,TPA ;lowest allowed load address + ld de,ddtz_base ;don't load over ddtz call cp_hl_de - jr c,error2 - ld de,(BDOS+1) ;highest allowed load address + jr nc,ist_1 + + ld de,(bitmap_end) call cp_hl_de jr nc,error2 +ist_1: ld de,(high_load) call cp_hl_de jr c,l1157h @@ -3784,6 +3868,7 @@ l208bh: scf ret +;jr, djnz l2093h: ld c,(iy+001h) ld a,c @@ -3827,6 +3912,8 @@ l20b8h: jr z,l20dch and a ret + +;ret cc l20c5h: ld a,(iy+000h) ld (l20d7h),a @@ -3844,6 +3931,7 @@ l20d7h: inc hl jp (hl) +;ret l20dch: l20edh: ld hl,(reg_sp) ;break on return address @@ -3852,10 +3940,12 @@ l20edh: ld d,(hl) ex de,hl call bp_trace_enter +;rst 8 l2115h: and a ret +;rst n l20f9h: ld a,(l0003h) cp (iy+000h) @@ -3864,9 +3954,6 @@ l20f9h: and 038h ld l,a ld h,000h - ld a,(b_21e2_start) - and a - ret z scf ret @@ -3960,9 +4047,12 @@ last_L: pbl_loop_adr: dw 0addeh +bitmap_end: + dw 0 + ;------------------------------------------------------------------------------- -conbuf:: +conbuf: ds CONBUF_SIZE+1 ;------------------------------------------------------------------------------- @@ -3970,7 +4060,7 @@ conbuf:: rept (STACK_SIZE+3)/4 db 0deh,0adh,0beh,0efh endm -stack:: +stack: reg.l2: db 000h reg.h2: db 000h reg.e2: db 000h @@ -3998,12 +4088,12 @@ reg.iff: reg.pc: dw TPA cmd_rpt:dw mainloop - + db 0ffh,0ffh,0ffh ;------------------------------------------------------------------------------- ddtz_size equ $-ddtz_base prog_size equ $-start -ddtz_end:: +ddtz_end: ;-------------------------------------------------------------------------------