Skip to content

Commit e93239e

Browse files
authored
Merge pull request #5 from nihirash/file_api_fixing
Development updates
2 parents 7f730d7 + f137a8e commit e93239e

File tree

12 files changed

+260
-24
lines changed

12 files changed

+260
-24
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024.05.02
1+
2024.05.04

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Changelog
22

3-
## 2024.04.02
3+
## 2024.05.04
4+
5+
* Very basic ADM-3 terminal emulation
6+
7+
* "Update random access pointer" call implemented
8+
9+
* "Printer" now outputs to VPD's printer
10+
11+
* Console status and reading working fine now
12+
13+
## 2024.05.02
414

515
* File leak fixed
616

src/config.asm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616

1717
;; Replace ZINC_BASE to $40000 for using it from `/bin` path or as standalone application
1818
;; Or keep it as usual moslet - emulator is really tiny and works fine here
19-
ZINC_BASE: equ $B0000
20-
ZINC_EXIT: equ ZINC_BASE + 4
19+
ZINC_BASE: equ $B0000
20+
ZINC_EXIT: equ ZINC_BASE + 4
21+
ZINC_TERMOUT: equ ZINC_EXIT + 4
2122

2223
;; By changing this value you can change used memory page for CP/M application
2324
EDOS_BASE: equ $A0000
2425
;; Origin address for EDOS(BDOS equivalent in ZINC)
2526
EDOS_ORG: equ EDOS_BASE + $F500
2627
;; TPA area starts here
2728
EDOS_TPA: equ EDOS_BASE + $100
29+
;; MB pointer
30+
EDOS_PAGE: equ EDOS_BASE / $10000
2831

2932
;; CP/M 2.2 is $22
3033
;; Personal CP/M-80 is $28

src/edos/console.asm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ raw_io:
4545
ret z
4646
jp CONIN
4747

48-
4948
get_io_byte:
5049
ld a, (IOBYTE)
5150
ret

src/edos/core.asm

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
TDRIVE: equ $04
88
IOBYTE: equ $03
99
TFCB: equ $5c
10+
DEFDMA: equ $80
1011

1112
NFUNC: equ 40
1213

@@ -73,8 +74,8 @@ fun_table:
7374
dw console_out ; 02 Console out
7475

7576
dw trace ; 03 Aux read
76-
dw trace ; 04 Aux write
77-
dw do_nothing ; 05 Printer write
77+
dw print ; 04 Aux write
78+
dw print ; 05 Printer write
7879

7980
dw raw_io ; 06 Raw IO
8081
dw get_io_byte ; 07 Get IO Byte
@@ -106,7 +107,7 @@ fun_table:
106107
dw fread_rnd ; 33 Random read
107108
dw fwrite_rnd ; 34 Random write
108109
dw calc_size ; 35 Compute file size
109-
dw trace ; 36 Update random access pointer
110+
dw calc_random_offset ; 36 Update random access pointer
110111
dw do_nothing ; 37 reset selected disks
111112
dw trace ; 38 not used in CP/M 2.2
112113
dw trace ; 39 not used in CP/M 2.2
@@ -116,6 +117,11 @@ fun_table:
116117
bye:
117118
jp.lil ZINC_EXIT
118119

120+
;; Just send byte to VDP "Printer"
121+
print:
122+
ld c, e
123+
jp list
124+
119125
do_nothing:
120126
xor a
121127
ld hl, 0

src/edos/disk.asm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,19 @@ catalog_scan_next:
7676
jr scan_ok
7777

7878
nope:
79-
ld a, $ff
79+
ld a, -1
80+
ld hl, -1
81+
ld bc, -1
8082
ret
8183

8284
scan_ok:
8385
ld de, (dma_ptr)
8486
ld hl, ffs_lfn
8587
call ascciz_to_fcb
86-
88+
8789
xor a
90+
ld hl, 0
91+
ld bc, 0
8892
ret
8993

9094
;; Calculation file lenght

src/edos/ebios/console.asm

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,52 @@
33
;;
44
;; All rights are reserved
55

6+
7+
;; Single source of truth is better
8+
keycode:
9+
db 0
10+
611
bios_const:
12+
ld.lil hl, (keycount_ptr)
13+
ld.lil a, (hl)
14+
and a
15+
ret z
16+
17+
ld.lil hl, (keydown_ptr)
18+
ld.lil a, (hl)
19+
and a
20+
ret z
21+
722
ld.lil hl, (keycode_ptr)
823
ld.lil a, (hl)
9-
or a
24+
and $7f
25+
ld (keycode), a
1026
ret z
1127

1228
ld a, $ff
1329
ret
1430

15-
1631
bios_in:
1732
;; You shouldn't use application stack(it will broke wordstar, for example)
1833
;; So, using our BIOS-stack for all places where we'll need stack
1934
LOCALSP
2035
@rep:
21-
MOSCALL MOS_GET_KEY
22-
or a
36+
call bios_const
37+
and a
2338
jr z, @rep
2439
25-
ld c, a
26-
27-
xor a
28-
ld.lil hl, (keycode_ptr)
40+
xor a
41+
ld.lil hl, (keydown_ptr)
2942
ld.lil (hl), a
3043

31-
ld a, c
44+
ld a, (keycode)
45+
3246
RESTORESP
3347
ret
3448

3549
bios_out:
3650
LOCALSP
3751
ld a, c
38-
rst.lil $10
52+
call.lil ZINC_TERMOUT
3953
RESTORESP
4054
ret

src/edos/ebios/index.asm

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CONST: JP bios_const
1515
CONIN: JP bios_in
1616
CONOUT: JP bios_out
1717

18-
LIST: JP nothing
18+
LIST: JP list
1919
PUNCH: JP nothing
2020
READER: JP reader
2121

@@ -33,6 +33,23 @@ nothing:
3333
ld a, $ff
3434
ret
3535

36+
list:
37+
LOCALSP
38+
39+
ld a, c
40+
ld (@char), a
41+
ld hl, @vdu
42+
ld bc, 4
43+
rst.lil $18
44+
45+
RESTORESP
46+
ret
47+
@vdu:
48+
db 2, 1
49+
@char:
50+
db 0
51+
db 3
52+
3653
reader:
3754
ld a, 26
3855
ret
@@ -60,9 +77,17 @@ init:
6077
rst.lil $18
6178

6279
MOSCALL MOS_SYS_VARS
63-
lea.lil hl, ix + 5 ;; ASCII KEYCODE
80+
81+
lea.lil hl, ix + VAR_KEYASCII ;; ASCII KEYCODE
6482
ld.lil (keycode_ptr), hl
6583

84+
lea.lil hl, ix + VAR_KEYDOWN ;; VKEYDOWN
85+
ld.lil (keydown_ptr), hl
86+
87+
lea.lil hl, ix + VAR_VKEYCOUNT ;; VKEYCOUNT
88+
ld.lil (keycount_ptr), hl
89+
90+
6691
;; Cleaning last keypress on start - no waiting for key on start of some apps
6792
xor a
6893
ld.lil (hl), a
@@ -78,7 +103,7 @@ init:
78103
ld hl, entrypoint
79104
ld (6), hl
80105

81-
ld bc, $80
106+
ld bc, DEFDMA
82107
ld (dma_ptr), bc
83108

84109
ld a, 1
@@ -88,6 +113,7 @@ init:
88113
jp bye
89114

90115
banner:
116+
db 4
91117
db 13,10, 17, 1
92118
db "ZINC is Not CP/M", 13, 10, 17, 2
93119
db "(c) 2024 Aleksandr Sharikhin", 13, 10, 17, 15
@@ -98,6 +124,10 @@ banner:
98124
include "ebios/console.asm"
99125
include "ebios/disk.asm"
100126

127+
keycount_ptr:
128+
dl 0
129+
keydown_ptr:
130+
dl 0
101131
keycode_ptr:
102132
dl 0
103133

src/edos/fcb.asm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ fcb_calc_offset:
3939
pop ix
4040
ret
4141

42+
calc_random_offset:
43+
push ix
44+
ld ix, (args)
45+
46+
ld l, (IX + FCB_EX)
47+
ld h, $80
48+
mlt hl
49+
50+
ld d, 0
51+
ld e, (IX + FCB_CR)
52+
53+
add hl, de
54+
55+
ld (ix + FCB_RN), hl
56+
57+
pop ix
58+
xor a
59+
ret
60+
4261
; IX - FCB
4362
fcb_next_record:
4463
push ix

src/edos/mos.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ FA_WRITE: equ $02
3636
FA_CREATE: equ $04
3737
FA_CREATE_ALW: equ $08
3838
FA_OPEN_ALW: equ $10
39+
40+
VAR_VKEYCOUNT: equ $19
41+
VAR_KEYASCII: equ $05
42+
VAR_KEYDOWN: equ $18

0 commit comments

Comments
 (0)