Jump to content
IGNORED

Adding a C64 disk drive ( 1541-71) to the Ti99/4a


mister35mm
 Share

Recommended Posts

This is a bit of a shaggy dog story... Apologies in advance.


Once upon a time, a bought a 2nd hand Sharp MZ721 computer (64k ram, Z80a, 2k monitor rom, BASIC etc loaded from tape.) It could be switched on, but I had no software for it, and even BASIC had to be loaded from cassette. Today, I was looking at one of the few Sharp computer 'fan' websites:- http://www.sharpmz.org/ to see what software I could find, I came across this interesting article about interfacing one of commodore's serial floppy disk drives to the Mz700's I/O port. Now you may or may not know that CBM / Commodore floppy drives, like Atari disk drives, have a built in microprocessor system with a kind of DOS built in. Communications are done via the particular computer's serial port. This article explains how to built the interface (one74ls06 series ic's) and programming on the MZ700. I was thinking with a little adaption, perhaps the same could be done with the TI-99/4a? The software is able to store storage areas on a Commodore 1541/1570/1571/1581 disk in conjunction with the simple hardware described above.


The following functions are available by this version of the software:


Save a storage area on disk

Verify the saved data

Load a machine code program or any data from disk to the memory

Display the directory from disk

Print the directory on the internal plotter or an external printer

Get and display the status message from the drive

Send a floppy command to the drive


LSVCDIPF :


Each character is the short form of a command. At the end of each process the program tries to get and display the drive status message, for example, 00, OK,00,00.


A description of the commands follows now.



"L" loads a machine code program into the memory. Example:


LSVCDIPF: L

Filename: MYFILE


Searching for MYFILE

Load to : C000

Searching for MYFILE

Loading MYFILE

00, OK,00,00


MYFILE is the file name of the file to be loaded. C000 is displayed by the program. C000 is the address typed in during the save process as the start address of the area to be saved. You can change the address if the data is to be loaded to a new location.



"S" saves a machine code program to disk. An example of the procedure follows:


LSVCDIPF: S

Filename: MYFILE


Begin : C000

End : CA94

Saving MYFILE

00, OK,00,00


The name of the file to be saved is MYFILE, for example. The data to be saved is located in the memory from $C000 to $CA94.



"V" verifies the data saved. Invoke the verify immediately afterwards of a save, otherwise, the data in the memory could be modified possibly. Example of the procedure:


LSVCDIPF: V

Searching for MYFILE

Verifying MYFILE

00, OK,00,00


Depending on possible write errors during a save or depending on a damaged disk the following messages are possible:


LSVCDIPF: V

Searching for MYFILE

Verifying MYFILE

Verifying error

00, OK,00,00


In this case take a new disk and save the file again.



"C" allows to invoke any available floppy drive command directly:


LSVCDIPF: C

Command : U0>M1


00, OK,00,00.


This example shows the mode change of the 1571 from the 1541 mode to the 1571 mode.



"D" gets the directory from the disk and stores the directory into the memory starting at the BASIC user programming area located at $6BCF for the S-BASIC like the C64 does. Then the directory is displayed on screen. If the screen is full the program waits until any key is pressed and then displays the next screen. Here is an example:


LSVCDIPF: D

Searching for $

Loading $


0 "MYDISK1 " 00 2A

13 "FILE1" PRG

17 "GAME002" PRG

12 "PROGRAMM UTI" PRG

1 "MYFILE2" PRG

1 "MYTEST" PRG

618BLOCKS FREE.


The first 3 messages will be overwritten by the directory display that follows.



"I" prints the directory on an external printer and "P" prints the directory on the internal plotter. The directory is stored into the memory as described above and additional, it is displayed on the screen too.


If the screen is full no key action is needed as needed for the "D" command. The program waits until the last character on the screen is printed and then automatically displays the next screen.


The current character printed is inverted on the screen to see the progress of the print output.



"F" gets and displays the floppy drive status message. An example follows:


LSVCDIPF: F

73,CBM DOS V3.0 1571,00,00


Another example is:


LSVCDIPF: F

74,DRIVE NOT READY,00,00


There is also a complete z80 assembly listing too:-


AS V1.40r8 - Quelle MZ1571.ASM - Seite 1 - 23.8.1998 0:23:26



1/ 0 : ; written by KarlHeinz.Mau@t-online.de 1996, last modified August 22nd, 1998

2/ 0 : ;

3/ 0 : ; This program communicates with Commodore 15xx floppy disk drive running

4/ 0 : ; on Sharp MZ700-series homecomputers.

5/ 0 : ;

6/ 0 : ; The following commands are implemented:

7/ 0 : ;

8/ 0 : ; "L" Load a file from 15xx. The load address is modifiable, the program

9/ 0 : ; displays the address where it was stored. You can use or modify this

10/ 0 : ; address. First you have to specify the name of the file to load.

11/ 0 : ;

12/ 0 : ; "S" Save a file to 15xx. You have to know the begin/end address for save

13/ 0 : ; and you have to specify the name of the file to save. The name of

14/ 0 : ; the file must not exceed 16 characters in length.

15/ 0 : ;

16/ 0 : ; "V" Verifies a stored file.

17/ 0 : ;

18/ 0 : ; "C" You can input and send any command decsribed in handbooks for 15xx to

19/ 0 : ; the drive.

20/ 0 : ;

21/ 0 : ; "F" Reads and displays the error message channel of the floppy drive.

22/ 0 : ;

23/ 0 : ; "D" Loads the directory to main storage at location 6bcfh and displays the

24/ 0 : ; directory.

25/ 0 : ; Note, loaded directory overwrites the basic program area, like

26/ 0 : ; the C64 does.

27/ 0 : ;

28/ 0 : ; "I" Outputs directory to printer.

29/ 0 : ;

30/ 0 : ; "P" Outputs directory to plotter.

31/ 0 : ;

32/ 0 :

33/ 0 :

34/ 0 : CPU Z80

35/ A000 : org 0a000h ; A000h Entrypoint MZ700

36/ A000 : C3 F5 A0 jp start ; jump around definitions

37/ A003 :

38/ A003 : ; MZ7xx-Characterset conversion

39/ A003 : CHARSET 'a',0a1h

40/ A003 : CHARSET 'b',09ah

41/ A003 : CHARSET 'c',09fh

42/ A003 : CHARSET 'd',09ch

43/ A003 : CHARSET 'e',092h

44/ A003 : CHARSET 'f',0aah

45/ A003 : CHARSET 'g',097h

46/ A003 : CHARSET 'h',098h

47/ A003 : CHARSET 'i',0a6h

48/ A003 : CHARSET 'j',0afh

49/ A003 : CHARSET 'k',0a9h

50/ A003 : CHARSET 'l',0b8h

51/ A003 : CHARSET 'm',0b3h

52/ A003 : CHARSET 'n',0b0h

53/ A003 : CHARSET 'o',0b7h

54/ A003 : CHARSET 'p',09eh

55/ A003 : CHARSET 'q',0a0h

56/ A003 : CHARSET 'r',09dh

57/ A003 : CHARSET 's',0a4h

58/ A003 : CHARSET 't',096h

59/ A003 : CHARSET 'u',0a5h

60/ A003 : CHARSET 'v',0abh

AS V1.40r8 - Quelle MZ1571.ASM - Seite 2 - 23.8.1998 0:23:26



61/ A003 : CHARSET 'w',0a3h

62/ A003 : CHARSET 'x',09bh

63/ A003 : CHARSET 'y',0bdh

64/ A003 : CHARSET 'z',0a2h

65/ A003 : CHARSET 'ä',0bbh

66/ A003 : CHARSET 'ö',0bah

67/ A003 : CHARSET 'ü',0adh

68/ A003 : CHARSET 'ß',0aeh

69/ A003 : CHARSET 'Ä',0b9h

70/ A003 : CHARSET 'Ö',0a8h

71/ A003 : CHARSET 'Ü',0b2h

72/ A003 :

73/ A003 : ; Monitor-ROM-entries

74/ A003 : =3H GETL: equ 0003h ; get input line to (de)

75/ A003 : =6H LETNL: equ 0006h ; set cursor to next line

76/ A003 : =12H PRNT: equ 0012h ; print character in accu

77/ A003 : =15H MSG: equ 0015h ; print character string from (de)

78/ A003 : =ADH ST1: equ 00adh ; entry of Monitor-ROM

79/ A003 : =18FH LPRNT: equ 018fh ; 1 Char. plot

80/ A003 : =3BAH PRTHL: equ 03bah ; ascii print for hl

81/ A003 : =3C3H PRTHX: equ 03c3h ; ascii print for accu

82/ A003 : =410H HLHEX: equ 0410h ; compute 4 ascii to hl

83/ A003 : =9B3H KEY: equ 09b3h ; waits for any key (accu=displ.code)

84/ A003 : =A50H SWEP: equ 0a50h ; checks for any key pressed

85/ A003 : =BCEH DACN: equ 0bceh ; converts display-code to ascii

86/ A003 : =BD4H dacn10: equ 0bd4h ; conversion routine

87/ A003 : =DB5H DSP: equ 0db5h ; prints display-code from accu

88/ A003 : =1171H DSPXY: equ 1171h ; 1171 curr. column, 1172 curr. row

89/ A003 : =6BCFH BasStrt: equ 6bcfh ; Start adress Basic-program area

90/ A003 : =D000H screen: equ 0d000h ; start of screen area

91/ A003 : =E000H le000: equ 0e000h ; 8255 Port A

92/ A003 : =E001H le001: equ 0e001h ; 8255 Port B

93/ A003 : =E008H le008: equ 0e008h ; LS367

94/ A003 :

95/ A003 : ; constants

96/ A003 :

97/ A003 : =AH lf: equ 0ah ; line feed + autom. cr for printer

98/ A003 : =DH cr: equ 0dh ; Carriage Return

99/ A003 : =16H cls: equ 16h ; Clear-Screen-Character

100/ A003 : =1BH brk2: equ 1bh ; MZ-code break

101/ A003 : =20H spc: equ 20h ; space-/blank-character

102/ A003 : =CBH brk1: equ 0CBh ; Keycode Break

103/ A003 : =66H cr2: equ 66h ; Keycode carriage return

104/ A003 :

105/ A003 : ; Definitions, variables, switches

106/ A003 : 4C 53 56 43 44 49 Prompt0: db "LSVCDIPF : \r" ; \r = 0Dh = Stringend

50 46 20 3A 20 0D

107/ A00F : 43 B7 B3 B3 A1 B0 Prompt1: db "Command : \r"

9C 20 20 3A 20 0D

108/ A01B : 4C B7 A1 9C 20 96 Prompt2: db "Load to : \r"

B7 20 20 3A 20 0D

109/ A027 : 42 92 97 A6 B0 20 Prompt3: db "Begin : \r"

20 20 20 3A 20 0D

110/ A033 : 45 B0 9C 20 20 20 Prompt4: db "End : \r"

20 20 20 3A 20 0D

111/ A03F : 46 A6 B8 92 B0 A1 Prompt5: db "Filename : \r"

B3 92 20 3A 20 0D

112/ A04B : 44 92 AB A6 9F 92 DEVNPRES: db "Device not present\r"

20 B0 B7 96 20 9E

9D 92 A4 92 B0 96

AS V1.40r8 - Quelle MZ1571.ASM - Seite 3 - 23.8.1998 0:23:26



0D

113/ A05E : 42 9D 92 A1 A9 0D Break: db "Break\r"

114/ A064 : 56 92 9D A6 AA BD veriferr: db "Verifying error\r"

A6 B0 97 20 92 9D

9D B7 9D 0D

115/ A074 : 53 A1 AB 92 20 92 saveerr: db "Save error\r"

9D 9D B7 9D 0D

116/ A07F : 4C B7 A1 9C 20 92 loaderr: db "Load error\r"

9D 9D B7 9D 0D

117/ A08A : 53 92 A1 9D 9F 98 searchfo: db "Searching for \r"

A6 B0 97 20 AA B7

9D 20 0D

118/ A099 : 4C B7 A1 9C A6 B0 loading: db "Loading \r"

97 20 0D

119/ A0A2 : 56 92 9D A6 AA BD veryfing: db "Verifying \r"

A6 B0 97 20 0D

120/ A0AD : 53 A1 AB A6 B0 97 saving: db "Saving \r"

20 0D

121/ A0B5 : 46 A6 B8 92 20 B0 filenfnd: db "File not found\r"

B7 96 20 AA B7 A5

B0 9C 0D

122/ A0C4 : 4D A6 A4 A4 A6 B0 namemiss: db "Missing filename\r"

97 20 AA A6 B8 92

B0 A1 B3 92 0D

123/ A0D5 :

124/ A0D5 : FF PrtSw: db 0ffh ; 'P'=Plot, not 'P'=print

125/ A0D6 : 00 lc401: db 00h ; 00h=go back to monitor,

126/ A0D7 : ; not 00h=goback to caller

127/ A0D7 : 00 00 stackptr: dw 0000h ; stack on entry to hardcopy routine

128/ A0D9 : 00 00 stckptr: dw 0000h ; stack pointer to return from errors

129/ A0DB :

130/ A0DB : ; IEC-Definitions

131/ A0DB :

132/ A0DB : 40 ST: db 40h ; (90h) means c64-zero-page,

133/ A0DC : ; Status word

134/ A0DC : 00 LVFlag: db 00h ; (93h) 00=load, 01=verify, 02=save

135/ A0DD : 55 iecflag: db 55h ; (94h) flag at IEC-output

136/ A0DE : 00 IECBUF: db 00h ; (95h) 1 byte IEC-buffer for

137/ A0DF : ; received byte

138/ A0DF : 55 sta: db 55h ; (a3h), IEC I/O-status

139/ A0E0 : 00 bitcnt: db 00h ; (a4h), IEC I/O-bit counter

140/ A0E1 : CD 00 EndPtr: dw 00cdh ; (aeh) current save-/load address

141/ A0E3 : 0D fileLen: db 0dh ; (b7h) length of file name

142/ A0E4 : 60 SecAdr: db 60h ; (b9h) secondary address

143/ A0E5 : 08 GerNr: db 08h ; (bah) device number (Floppy icon_cool.gif

144/ A0E6 : 00 00 IOStrt: dw 0000h ; (c1h) start address

145/ A0E8 : C1 00 AdrLoad: dw 00c1h ; load address for file/directory

146/ A0EA : 00 02 biostrt: dw 0200h ; save start address

147/ A0EC : 00 asave: db 00h ; save for accu

148/ A0ED : 00 hlsave: db 0000h ; save for hl

149/ A0EE : B5 zwispei: db 0b5h ; save for received bit(s)

150/ A0EF : 4E svsecadr: db 4eh ; save sec. address

151/ A0F0 : 30 30 30 30 30 ascwork: db "00000" ; workarea ascii-convertion

152/ A0F5 :

AS V1.40r8 - Quelle MZ1571.ASM - Seite 4 - 23.8.1998 0:23:26



153/ A0F5 : NEWPAGE

154/ A0F5 :

155/ A0F5 : ; Entrypoint

156/ A0F5 :

157/ A0F5 : 11 03 A0 start: ld de,Prompt0 ; (prompt0)

158/ A0F8 : CD 56 A1 call inptproc

159/ A0FB : CA 7E A8 jp z,intbrk

160/ A0FE : CD CE 0B call DACN ; convert display code to ascii

161/ A101 : FE 66 cp cr2 ; enter (cr) key pressed?

162/ A103 : CA F5 A0 jp z,start ; yes, once more

163/ A106 : ED 73 D9 A0 ld (stckptr),sp ; save stackpointer for errors

164/ A10A : FE 43 cp 'C' ; C to put any command on floppydrive

165/ A10C : CA 6B A1 jp z,cmdin ; yes, jump in

166/ A10F : FE 44 cp 'D' ; D to get directory on screen

167/ A111 : CA 37 A1 jp z,start015 ; yes, jump in

168/ A114 : FE 46 cp 'F' ; F to get 15xx error message

169/ A116 : CA 15 A2 jp z,GetErSta ; yes, jump in

170/ A119 : FE 4C cp 'L' ; L to load a file

171/ A11B : CA 43 A2 jp z,Load ; yes, jump in

172/ A11E : FE 53 cp 'S' ; S to save a file

173/ A120 : CA A7 A2 jp z,Save ; yes, jump in

174/ A123 : FE 56 cp 'V' ; V to verify a stored file

175/ A125 : CA 96 A2 jp z,Verify ; yes, jump in

176/ A128 : FE 50 cp 'P' ; P to plot directory

177/ A12A : C2 3D A1 jp nz,start020 ; no, try 'I'

178/ A12D : 3E 40 ld a,40h ; set IRT bit

179/ A12F : D3 FE out (0feh),a ; IRT plotter (reset)

180/ A131 : 3E 00 ld a,00h ; clr lines

181/ A133 : D3 FE out (0feh),a

182/ A135 : 3E 50 ld a,'P'

183/ A137 : 32 D5 A0 start015: ld (PrtSw),a ; store to print marker

184/ A13A : C3 85 A1 jp getdir ; continue

185/ A13D :

186/ A13D : FE 49 start020: cp 'I' ; I to print directory?

187/ A13F : 20 B4 jr nz,start ; no, error, once more

188/ A141 : 32 D5 A0 ld (PrtSw),a ; store to print marker

189/ A144 : DB FE start030: IN A,(0FEh)

190/ A146 : CB 47 BIT 0,A ; busy?

191/ A148 : 28 3B JR Z,getdir ; not busy

192/ A14A : F6 40 OR 40h ; set IRT

193/ A14C : D3 FE OUT (0FEh),A ; reset printer

194/ A14E : CD B1 A3 CALL lC719 ; test break key

195/ A151 : 20 F1 JR NZ,start030 ; no, loop

196/ A153 : C3 7E A8 jp intbrk ; yes, goback

197/ A156 :

198/ A156 : CD 15 00 inptproc: call MSG ; print message (de)

199/ A159 : CD B3 09 inptp10: call KEy ; wait on any key. (display code)

200/ A15C : FE CB cp brk1 ; break key pressed?

201/ A15E : C8 ret z ; yes, jump to break routine

202/ A15F : FE C1 cp 0c1h ; don't show keys (c1h-cdh)cc?

203/ A161 : DC B5 0D call c,DSP ; echo key to screen

204/ A164 : F5 push af ; save key code

205/ A165 : CD 06 00 call LETNL ; skip cursor to next line

206/ A168 : F1 pop af ; restore

207/ A169 : A7 and a ; no break (note: test space bar?)

208/ A16A : C9 ret

209/ A16B :

210/ A16B : ; input for a 157xx-command that is to send to drive

211/ A16B : 11 0F A0 cmdin: ld de,prompt1 ; address of prompt1 to de

212/ A16E : CD 04 A3 call GetNam05 ; get command input line

AS V1.40r8 - Quelle MZ1571.ASM - Seite 5 - 23.8.1998 0:23:26



213/ A171 : CA 7E A8 jp z,intbrk ; jump if break key or cr key pressed

214/ A174 : 3E 0F ld a,0fh ; command channel 0fh

215/ A176 : 32 E4 A0 ld (SecAdr),a ; store in

216/ A179 : CD BD A6 call IECOPEN ; open cmd channel and submit cmd

217/ A17C : CD 20 A8 call IECCLOSE ; close cmd channel

218/ A17F : CD BC A4 call ErrorChk ; check for errors

219/ A182 : C3 15 A2 jp GetErSta ; all done, displ. error msg channel

220/ A185 :

221/ A185 :

222/ A185 : ; Load and display directory

223/ A185 :

224/ A185 : AF GetDir: xor a ; 00=Load directory

225/ A186 : 32 DC A0 ld (LVFlag),a

226/ A189 : 3C inc a ; 00+01

227/ A18A : 32 E3 A0 ld (fileLen),a ; "$" is length of 1

228/ A18D : 3E 24 ld a,'$' ; $ is 157xx command to load directory

229/ A18F : 32 9B A8 ld (fileName+11),a ; $ to the command line

230/ A192 : 21 CF 6B ld hl,BasStrt ; area to store the directory info

231/ A195 : 22 E8 A0 ld (AdrLoad),hl ; save adress for load routine

232/ A198 : AF xor A

233/ A199 : 32 E4 A0 LD (SecAdr),a ; dir load transfer on channel 0

234/ A19C : CD 10 A7 call IECLOAD ; exec load routine

235/ A19F : CD BC A4 call ErrorChk ; check for errors

236/ A1A2 : DA 7E A8 jp c,intbrk ; stop at brk

237/ A1A5 : 11 CF 6B ld de,BasStrt ; address of directory info in main

238/ A1A8 : 3E 16 DirPrt05: ld a,cls ; first clear the screen

239/ A1AA : CD 12 00 call prnt ; do it

240/ A1AD : 13 DirPrt10: inc de ; skip around two 01h

241/ A1AE : 13 inc de

242/ A1AF : EB ex de,hl

243/ A1B0 : 5E ld e,(hl) ; load # of blocks to de

244/ A1B1 : 23 inc hl

245/ A1B2 : 56 ld d,(hl)

246/ A1B3 : 23 inc hl

247/ A1B4 : EB ex de,hl ; now to hl for hltoasc

248/ A1B5 : CD 69 A4 call HLtoASC ; print # blocks

249/ A1B8 : 1A DirPrt20: ld a,(de) ; check for line end

250/ A1B9 : A7 and a

251/ A1BA : 28 0C jr z,DirPrt40 ; yes, line end reached

252/ A1BC : FE 20 cp spc ; check for C64 reverse on 12h and

253/ A1BE : 30 02 jr nc,DirPrt30 ; other non displayable codes

254/ A1C0 : 3E 20 ld a,spc ; yes, force them to space

255/ A1C2 : CD 12 00 DirPrt30: call prnt ; Display character

256/ A1C5 : 13 inc de ; next char form dir

257/ A1C6 : 18 F0 jr DirPrt20 ; continue at this line

258/ A1C8 :

259/ A1C8 : 13 DirPrt40: inc de

260/ A1C9 : 1A ld A,(de) ; check end of directory

261/ A1CA : A7 and a ; (2nd 00h means end of dir)

262/ A1CB : 20 20 jr nz,dirprt50 ; no, continue

263/ A1CD : 3A D5 A0 ld a,(prtsw) ; yes, process end of dir now

264/ A1D0 : FE 44 cp 'D' ; screen only?

265/ A1D2 : 20 06 jr nz,dirprt45 ; no, output too

266/ A1D4 : CD 06 00 dirprt43: call letnl ; set cursor to next line on screen

267/ A1D7 : C3 F5 A0 jp start ; goback

268/ A1DA :

269/ A1DA : 3E FF dirprt45: ld a,0ffh ; lc692 uses ret command and not jump

270/ A1DC : 32 D6 A0 ld (lc401),a ; to monitor for returning

271/ A1DF : CD 4C A3 call lc692 ; print/plot

272/ A1E2 : CA 7E A8 jp z,intbrk

AS V1.40r8 - Quelle MZ1571.ASM - Seite 6 - 23.8.1998 0:23:26



273/ A1E5 : CD A2 A3 call lc713 ; new line char printer/plotter

274/ A1E8 : CA 7E A8 jp z,intbrk ; stop at brk condition

275/ A1EB : 18 E7 jr dirprt43 ; go endprocess

276/ A1ED :

277/ A1ED : 3A 72 11 dirprt50: ld a,(DSPXY+1) ; get row number from systemarea

278/ A1F0 : FE 18 cp 24 ; screen full?

279/ A1F2 : 20 1C jr nz,DirPrt60 ; no, do new line on screen

280/ A1F4 : 3A D5 A0 ld a,(prtsw)

281/ A1F7 : FE 44 cp 'D' ; dir to screen only?

282/ A1F9 : 28 0D jr z,dirprt55 ; yes

283/ A1FB : 3E FF ld a,0ffh ; no, force return of lc692 to me

284/ A1FD : 32 D6 A0 ld (lc401),a ; and not to monitor

285/ A200 : CD 4C A3 call lc692 ; hardcopy screen

286/ A203 : CA 7E A8 jp z,intbrk ; brk condition during hardcopy

287/ A206 : 18 A0 jr dirprt05 ; cls, next screen

288/ A208 :

289/ A208 : CD AE A4 dirprt55: call WaitKey ; yes, wait on any key

290/ A20B : CA 7E A8 jp z,intbrk ; break key stops process

291/ A20E : 18 98 jr DirPrt05 ; do next line after clear screen

292/ A210 :

293/ A210 : CD 06 00 DirPrt60: call LETNL ; set cursor to new line

294/ A213 : 18 98 jr DirPrt10 ; and continue process

295/ A215 :

296/ A215 : ; Get and display message from drive

297/ A215 :

298/ A215 : AF GetErSta: xor A

299/ A216 : 32 DB A0 LD (ST),a ; clear status byte

300/ A219 : 3A E5 A0 ld a,(GerNr) ; set device number

301/ A21C : CD F3 A4 call SentTalk ; force device to init talk

302/ A21F : 3E 6F ld a,6fh

303/ A221 : CD BF A5 call SentSAdr ; init device with parameters

304/ A224 : CD 13 A6 GetSta10: call IECIN ; get 1 character from device

305/ A227 : F5 push af ; save gotten character

306/ A228 : 3A DB A0 ld a,(ST) ; check device status

307/ A22B : A7 and a

308/ A22C : 28 0F jr z,GetSta20 ; ok, continue

309/ A22E : CD 06 00 call letnl ; CR/new line

310/ A231 : 3A DB A0 ld a,(st)

311/ A234 : FE C2 cp 0c2h ; device not present status

312/ A236 : CA 55 A8 jp z,f707 ; stop on error

313/ A239 : F1 pop af ; end, restore accu

314/ A23A : C3 F5 A0 jp start ; done

315/ A23D :

316/ A23D : F1 GetSta20: pop af ; restore gotten character

317/ A23E : CD 12 00 call PRNT ; no, print the character on screen

318/ A241 : 18 E1 jr GetSta10 ; and continue

319/ A243 :

320/ A243 : ; Load file

321/ A243 :

322/ A243 : CD 01 A3 Load: call GetNam ; input file name

323/ A246 : CA 7E A8 jp z,intbrk ; stop if break or cr

324/ A249 : DA 43 A2 jp c,load ; again on any input error

325/ A24C : AF xor a

326/ A24D : 32 DC A0 ld (LVFlag),a ; 00h=Load

327/ A250 : 3E C9 ld a,0c9h ; at first get old address to store

328/ A252 : 32 49 A7 ld (MdfCmd02),a ; so read first two bytes only

329/ A255 : CD 10 A7 call IECLOAD ; do incomplete load first

330/ A258 : CD 94 A7 call F528 ; untalk and close file

331/ A25B : CD BC A4 call ErrorChk ; check for error

332/ A25E : 3E 3A ld a,3ah ; remodify load routine

AS V1.40r8 - Quelle MZ1571.ASM - Seite 7 - 23.8.1998 0:23:26



333/ A260 : 32 49 A7 ld (MdfCmd02),a ; for complete work again

334/ A263 : DA 15 A2 jp c,GetErSta ; get error msg on error

335/ A266 : 3A DB A0 ld a,(ST) ; same on incorrect device status

336/ A269 : A7 and a

337/ A26A : C2 15 A2 jp nz,GetErSta

338/ A26D : 11 1B A0 Load20: ld de,Prompt2 ; set de to address of prompt2

339/ A270 : CD 15 00 call MSG ; and print prompt2

340/ A273 : 2A E1 A0 ld hl,(EndPtr) ; get old store address to hl

341/ A276 : CD BA 03 call PRTHL ; and print old store address

342/ A279 : 11 E0 A8 ld de,BUFL ; set address of input buffer

343/ A27C : CD 03 00 call GETL ; get input line (store address)

344/ A27F : 1A ld a,(de)

345/ A280 : FE 1B cp brk2 ; break?

346/ A282 : CA 7E A8 jp z,intbrk ; yes, stop

347/ A285 : 11 EB A8 ld de,BUFL+11 ; address of input

348/ A288 : CD 10 04 call HLHEX ; translate ascii-hex to hl

349/ A28B : 38 E0 jr c,Load20 ; no hex data, once more

350/ A28D : 22 E8 A0 ld (AdrLoad),hl ; ok, save store address

351/ A290 : AF xor a

352/ A291 : 32 E4 A0 ld (secadr),a ; means load to (adrload)

353/ A294 : 18 03 jr Verify10 ; jump around verify, load 00 to accu

354/ A296 :

355/ A296 : ; verify saved file

356/ A296 :

357/ A296 : 3E 01 Verify: ld a,01h ; 01=verify

358/ A298 : 21 db 21h ; dummy instruction ld hl,3e00h

359/ A299 : 3E 00 verify10: ld a,00h ; 00=load

360/ A29B : 32 DC A0 ld (LVFlag),a ; store

361/ A29E : CD 10 A7 call IECLOAD ; load file

362/ A2A1 : CD BC A4 call ErrorChk ; check for error

363/ A2A4 : C3 15 A2 jp GetErSta ; print error/ok message

364/ A2A7 :

365/ A2A7 : ; Save file

366/ A2A7 :

367/ A2A7 : CD 01 A3 Save: call GetNam ; get data set name

368/ A2AA : CA 7E A8 jp z,intbrk ; stop on brk key

369/ A2AD : 38 F8 jr c,save ; on error again

370/ A2AF : 11 27 A0 Save10: ld de,Prompt3

371/ A2B2 : CD 15 00 call MSG ; display prompt3

372/ A2B5 : 11 E0 A8 ld de,BUFL

373/ A2B8 : CD 03 00 call GETL ; get input to bufl (start address)

374/ A2BB : 1A ld a,(de) ; check for brk

375/ A2BC : FE 1B cp brk2

376/ A2BE : CA 7E A8 jp z,intbrk ; stop

377/ A2C1 : 11 EB A8 ld de,BUFL+11 ; 1st input char

378/ A2C4 : 1A ld a,(de)

379/ A2C5 : FE 0D cp cr ; if no input again

380/ A2C7 : 28 E6 jr z,Save10

381/ A2C9 : CD 10 04 call HLHEX ; ascii to hex in hl

382/ A2CC : 38 E1 jr c,Save10 ; if not hex again

383/ A2CE : 22 E6 A0 ld (IOStrt),hl ; store in start address

384/ A2D1 : 11 33 A0 Save20: ld de,Prompt4

385/ A2D4 : CD 15 00 call MSG ; display prompt4

386/ A2D7 : 11 E0 A8 ld de,BUFL

387/ A2DA : CD 03 00 call GETL ; get input to bufl (end address)

388/ A2DD : 1A ld a,(de)

389/ A2DE : FE 1B cp brk2 ; check for brk key

390/ A2E0 : CA 7E A8 jp z,intbrk ; stop on brk

391/ A2E3 : 11 EB A8 ld de,BUFL+11

392/ A2E6 : 1A ld a,(de) ; get 1st input char

AS V1.40r8 - Quelle MZ1571.ASM - Seite 8 - 23.8.1998 0:23:26



393/ A2E7 : FE 0D cp cr ; check for no input

394/ A2E9 : 28 E6 jr z,Save20 ; if cr only again

395/ A2EB : CD 10 04 call HLHEX ; ascii to hex and put it to hl

396/ A2EE : 38 E1 jr c,Save20 ; on hex-error again

397/ A2F0 : 22 E1 A0 ld (EndPtr),hl ; save end address

398/ A2F3 : 3E 02 ld a,02h

399/ A2F5 : 32 DC A0 ld (LVFlag),a ; 02 means iecstor has to save data

400/ A2F8 : CD D1 A7 call IECSTORE ; exec save on disk

401/ A2FB : CD BC A4 call ErrorChk ; test for errors

402/ A2FE : C3 15 A2 jp GetErSta ; display floppy status message

403/ A301 :

404/ A301 : ; get file or other input to fileNAME

405/ A301 :

406/ A301 : 11 3F A0 GetNam: ld de,Prompt5 ; Address of prompt5 to de

407/ A304 : CD 15 00 GetNam05: call MSG ; put prompt5 on screen

408/ A307 : 11 90 A8 ld de,fileName ; address of input area

409/ A30A : CD 03 00 call GETL ; get input from keyboard

410/ A30D : CD 06 00 call LETNL ; set cursor to new line

411/ A310 : 3A 90 A8 ld a,(filename) ; get 1st char from input

412/ A313 : FE 1B cp brk2 ; break?

413/ A315 : C8 ret z ; yes, goback

414/ A316 : 11 9B A8 ld de,filename+11

415/ A319 : 1A ld a,(de) ; get 1st char from input line

416/ A31A : FE 0D cp cr ; test for cr

417/ A31C : C8 ret z ; goback if no further input

418/ A31D : 06 01 ld b,01h ; init length of name

419/ A31F : FE 0D GetNam10: cp cr ; end of name?

420/ A321 : 28 0C jr z,GetNam20 ; yes, stop testing and counting

421/ A323 : FE 20 cp spc ; valid name must be in the range of

422/ A325 : D8 ret c ; 20h and 5fh

423/ A326 : FE 5F cp 5fh

424/ A328 : 3F ccf ; carry is set if not

425/ A329 : D8 ret c

426/ A32A : 04 inc b ; count length

427/ A32B : 13 inc de ; next byte address of name

428/ A32C : 1A ld a,(de) ; get next byte of input

429/ A32D : 18 F0 jr GetNam10 ; continue

430/ A32F :

431/ A32F : 78 GetNam20: ld a,b ; length to accu

432/ A330 : 3D dec a ; adjust to correct length in accu

433/ A331 : 32 E3 A0 ld (fileLen),a ; save length

434/ A334 : FE 11 cp 17 ; must not exceed 16 chars in length

435/ A336 : 3F ccf ; carry means wrong length

436/ A337 : 3C inc a

437/ A338 : 3D dec a

438/ A339 : C9 ret ; goback to caller

439/ A33A :

440/ A33A : ; the following code is yet sleeping,

441/ A33A : ; it's for dir cmd if basic is active. The coding is under test.

442/ A33A : ; sets pointers of basic like cmd NEW does, but dir is still stored in

443/ A33A : ; basic's program area.

444/ A33A : ;

445/ A33A : ; another code is in progress for save and load, if basic is active

446/ A33A : ; and the user wants to save or load a basic program.

447/ A33A : ;

448/ A33A : ;bas: ld hl,(6abfh)

449/ A33A : ; ld a,6bh

450/ A33A : ; cp h

451/ A33A : ; ret nz

452/ A33A : ; ld a,0cfh

AS V1.40r8 - Quelle MZ1571.ASM - Seite 9 - 23.8.1998 0:23:26



453/ A33A : ; ret nz

454/ A33A : ; ld hl,(endptr)

455/ A33A : ; ld (6ab3h),hl

456/ A33A : ; call 224eh

457/ A33A : ; ret

458/ A33A : ;

459/ A33A : ;startxx: call bas

460/ A33A : ; jp getdir

461/ A33A :

462/ A33A :

463/ A33A : ; if accu=f0h (display code for space) then accu=space

464/ A33A :

465/ A33A : FE F0 lC674: CP 0F0h ; display code f0h? (space)

466/ A33C : C0 RET NZ ; no

467/ A33D : E6 20 AND 20h ; yes, put space

468/ A33F : C9 RET ; goback

469/ A340 :

470/ A340 : ; test shift-break

471/ A340 :

472/ A340 : 3E F8 lC686: LD A,0F8h ; column brk/ctrl/shift

473/ A342 : 32 00 E0 LD (lE000),A ; Port A 8255 send keyboard f8h

474/ A345 : 00 NOP ; wait 1 nop

475/ A346 : 3A 01 E0 LD A,(lE001) ; Port B 8255 receive keyboard data

476/ A349 : FE 7E CP 7Eh ; shift + brk ?

477/ A34B : C9 RET ; goback

478/ A34C :

479/ A34C : ; hardcopy entry

480/ A34C :

481/ A34C : C5 lc692: push bc ; save caller's regs

482/ A34D : D5 push de

483/ A34E : E5 push hl

484/ A34F : ED 73 D7 A0 ld (stackptr),sp ;

485/ A353 : 21 00 D0 LD HL,screen ; address to screen area

486/ A356 : E5 PUSH HL ; save for futher use

487/ A357 : E1 lC6C4: POP HL ; addr. of current row in screen

488/ A358 : E5 PUSH HL ; back for further use

489/ A359 : 06 28 LD B,40 ; init loop counter (40 columns/row)

490/ A35B : 16 00 LD D,00h

491/ A35D : 58 LD E,B ; DE is displacement to next row

492/ A35E : 19 ADD HL,DE ; HL is address to next row on screen

493/ A35F : 3E D4 LD A,0D4h ; check for last row (starts at

494/ A361 : BC CP H ; address d410h)

495/ A362 : 20 08 JR NZ,lC6D6 ; not last

496/ A364 : 3E 10 LD A,10h

497/ A366 : BD CP L

498/ A367 : 20 03 JR nZ,lC6d6 ; not last

499/ A369 : A7 and a ; accu is 10h, 'and a' sets NZ=no brk

500/ A36A : 18 56 JR lC72Cn ; goback

501/ A36C :

502/ A36C : D1 lC6D6: POP DE ; exchange entries on stack

503/ A36D : E5 PUSH HL ; contains address of next row

504/ A36E : D5 PUSH DE ; contains address of current row

505/ A36F : 2B lC6D9: DEC HL ; skip backwards subsequent spaces

506/ A370 : 7E LD A,(HL) ; get char

507/ A371 : B7 OR A ; space?

508/ A372 : 20 05 JR NZ,lC6E3 ; no, start outputting, notice,

509/ A374 : ; b-reg contains # of char to output

510/ A374 : 10 F9 DJNZ lC6D9 ; yes,skip space

511/ A376 : E1 POP HL ; full space line rebuild stack

512/ A377 : 18 DE JR lC6C4 ; process next row

AS V1.40r8 - Quelle MZ1571.ASM - Seite 10 - 23.8.1998 0:23:26



513/ A379 :

514/ A379 : E1 lC6E3: POP HL ; curr. column address in curr. row

515/ A37A : CB DC lc6e7: SET 3,H ; address to screen color

516/ A37C : 3E 17 LD A,17h ; color of char blue, backgrd. white

517/ A37E : 77 LD (HL),A ; set to invert value

518/ A37F : CB 9C RES 3,H ; address back to the char. screen

519/ A381 : 7E LD A,(HL) ; get char to output

520/ A382 : CD 35 A4 CALL lC78E ; convert displ. code to ascii

521/ A385 : B7 OR A ; 00h?

522/ A386 : 20 02 JR NZ,lC6FC ; no

523/ A388 : F6 20 OR 20h ; yes, force space on output

524/ A38A : CD 05 A4 lC6FC: CALL lC75B ; output 1 char

525/ A38D : CA BC A3 jp z,lc72c ; brk condition occured

526/ A390 : CB DC SET 3,H ; address to screen color

527/ A392 : 3E 71 LD A,71h ; color of char white, backgrd. blue

528/ A394 : 77 LD (HL),A ; reset to normal value

529/ A395 : CB 9C RES 3,H ; address back to the char. screen

530/ A397 : 23 INC HL ; next char

531/ A398 : 10 E0 DJNZ lC6E7 ; loop if length(contents of row)>0

532/ A39A : CD A2 A3 call lc713 ; set pen to next line

533/ A39D : CA C2 A3 jp z,lc72cn ; brk condition occured

534/ A3A0 : 18 B5 JR lC6C4 ; loop for next row

535/ A3A2 :

536/ A3A2 : ; skip to new line (for both, printer/plotter)

537/ A3A2 :

538/ A3A2 : 3A D5 A0 lc713: ld a,(prtsw) ;

539/ A3A5 : FE 50 cp 'P' ; plotter?

540/ A3A7 : 3E 0D ld a,cr ; cr for plotter

541/ A3A9 : 28 02 jr z,lc715 ; yes, do cr

542/ A3AB : 3E 0A ld a,lf ; no, lf for printer

543/ A3AD : CD 05 A4 lc715: call lc75b ; output cr or lf

544/ A3B0 : C9 ret

545/ A3B1 :

546/ A3B1 : ; goes back to monitor, if brk key used and started from monitor

547/ A3B1 : ; else returns if brk key used and called by program

548/ A3B1 : CD 40 A3 lC719: CALL lC686 ; test brk key

549/ A3B4 : C0 RET NZ ; no, continue

550/ A3B5 : CD 40 A3 lC71D: CALL lC686 ; test again and

551/ A3B8 : 28 FB JR Z,lC71D ; wait until unpressed

552/ A3BA : AF xor a ; zero flag indicates break

553/ A3BB : C9 ret

554/ A3BC :

555/ A3BC : CB DC lc72c: SET 3,H ; address to screen color

556/ A3BE : 3E 71 LD A,71h ; color of char white, backgrd. blue

557/ A3C0 : 77 LD (HL),A ; reset to normal value, may be inv.

558/ A3C1 : AF xor a ; set zflag (brk condition)

559/ A3C2 : F5 lC72Cn: push af ; save zero flag (z=brk, nz=no brk)

560/ A3C3 : 3A D6 A0 LD A,(lC401) ; 0 means jumped into program by mon.

561/ A3C6 : A7 AND A ; >0 means called by any program

562/ A3C7 : CA 8A A8 JP z,intrpt ; goback to monitor

563/ A3CA : AF XOR A ; prepare next execution parameters

564/ A3CB : 32 D6 A0 LD (lC401),A

565/ A3CE : F1 pop af ; notice zflag to caller

566/ A3CF : ED 7B D7 A0 ld sp,(stackptr)

567/ A3D3 : E1 pop hl ; restore caller's reg's

568/ A3D4 : D1 POP DE

569/ A3D5 : C1 POP BC

570/ A3D6 : C9 ret ; goback to caller

571/ A3D7 :

572/ A3D7 : ; plot 1 character

AS V1.40r8 - Quelle MZ1571.ASM - Seite 11 - 23.8.1998 0:23:26



573/ A3D7 :

574/ A3D7 : C5 lC73B: PUSH BC ; save callers reg

575/ A3D8 : 0E 00 LD C,00h ; 00h=ready

576/ A3DA : 47 LD B,A ; save

577/ A3DB : CD F5 A3 CALL lC753 ; wait on ready

578/ A3DE : 28 13 jr z,lc738bn ; stop on brk

579/ A3E0 : 78 LD A,B ; restore char to plot

580/ A3E1 : D3 FF OUT (0FFh),A ; data to plotter

581/ A3E3 : 3E 80 LD A,80h ; RDP (strobe) high

582/ A3E5 : D3 FE OUT (0FEh),A ; to plotter

583/ A3E7 : 0E 01 LD C,01h ; RDA test

584/ A3E9 : CD F5 A3 CALL lC753 ; wait (ack)

585/ A3EC : 28 05 jr z,lc738bn ; stop on brk

586/ A3EE : AF XOR A

587/ A3EF : D3 FE OUT (0FEh),A ; RDP low

588/ A3F1 : 2F cpl

589/ A3F2 : A7 and a ; NZ=no brk

590/ A3F3 : C1 lc738bn: POP BC ; restore callers reg

591/ A3F4 : C9 RET ; goback to caller

592/ A3F5 :

593/ A3F5 : DB FE lC753: IN A,(0FEh)

594/ A3F7 : E6 0D AND 00Dh ; RDA only

595/ A3F9 : B9 CP C ; test busy

596/ A3FA : 20 03 jr nZ,lc753n ; not busy

597/ A3FC : 2F lc753v: cpl ; ffh/feh

598/ A3FD : A7 and a ; indicate no break (NZ)

599/ A3FE : C9 ret

600/ A3FF :

601/ A3FF : CD B1 A3 lc753n: call lc719 ; test break key

602/ A402 : 20 F1 JR nz,lC753 ; wait on ready

603/ A404 : C9 ret ; zflag=brk condition

604/ A405 :

605/ A405 : ; outputs 1 character to plotter if (lc3fc) = "P"

606/ A405 : ; else to printer

607/ A405 :

608/ A405 : 4F lC75B: LD C,A ; save char to output

609/ A406 : 3A D5 A0 LD A,(prtsw) ; get user's input char

610/ A409 : FE 50 CP 'P' ; "P"?

611/ A40B : 79 LD A,C ; get back char to output

612/ A40C : 28 C9 JR Z,lC73B ; yes, go plot 1 char

613/ A40E : DB FE lC764: IN A,(0FEh) ; get state of printer

614/ A410 : CB 47 BIT 0,A ; busy?

615/ A412 : 28 06 JR Z,lC772 ; no, continue

616/ A414 : CD B1 A3 CALL lC719 ; yes, busy, brk key?

617/ A417 : 20 F5 JR NZ,lC764 ; no. Wait on ready

618/ A419 : C9 Ret ; goback with brk condition

619/ A41A :

620/ A41A : ; print 1 char

621/ A41A :

622/ A41A : 79 lC772: LD A,C ; get back char to print

623/ A41B : D3 FF OUT (0FFh),A ; data out

624/ A41D : DB FE IN A,(0FEh) ; get state of printer

625/ A41F : E6 7F AND 7Fh ; set strobe

626/ A421 : D3 FE OUT (0FEh),A ; put strobe

627/ A423 : DB FE IN A,(0FEh) ; get state again

628/ A425 : F6 80 OR 80h ; reset strobe

629/ A427 : D3 FE OUT (0FEh),A ; put out

630/ A429 : DB FE lC781: IN A,(0FEh) ; get state

631/ A42B : CB 47 BIT 0,A ; test busy

632/ A42D : 28 CD jr Z,lc753v ; not busy, goback to caller

AS V1.40r8 - Quelle MZ1571.ASM - Seite 12 - 23.8.1998 0:23:26



633/ A42F : CD B1 A3 CALL lC719 ; brk key?

634/ A432 : 20 F5 JR NZ,lC781 ; no, wait on ready (printed)

635/ A434 : C9 Ret ; yes, goback, brk

636/ A435 :

637/ A435 : ; display to ascii for printer or plotter

638/ A435 :

639/ A435 : F5 lC78E: PUSH AF ; save char to output

640/ A436 : 3A D5 A0 LD A,(prtsw) ; users input char

641/ A439 : FE 50 CP 'P' ; "P" (plotter)?

642/ A43B : 20 10 JR NZ,lC79D ; no, printer

643/ A43D : F1 POP AF ; char to plot

644/ A43E : CD 44 A4 CALL lC66B ; display to ascii (plotter)

645/ A441 : C3 3A A3 JP lC674

646/ A444 :

647/ A444 : ; display to ascii conversion for plotter

648/ A444 : ; returns from monitor to caller

649/ A444 :

650/ A444 : C5 lc66b: PUSH BC ; save own regs

651/ A445 : E5 PUSH HL

652/ A446 : D5 PUSH DE

653/ A447 : 21 36 A9 LD HL,lC402 ; my translation table for plotter

654/ A44A : C3 D4 0B JP dacn10 ; use monitor's conversion routine

655/ A44D :

656/ A44D :

657/ A44D : F1 lC79D: POP AF

658/ A44E : CD 54 A4 CALL lC7A4 ; display to ascii conversion

659/ A451 : C3 3A A3 JP lC674 ; if 0f0h conv. to spc, then goback

660/ A454 :

661/ A454 : ; diplay to ascii conversion for printer

662/ A454 :

663/ A454 : C5 lC7A4: PUSH BC ; save callers reg

664/ A455 : E5 PUSH HL

665/ A456 : D5 PUSH DE

666/ A457 : 21 36 AA LD HL,lC508 ; table display to ascii (printer)

667/ A45A : 4F LD C,A

668/ A45B : 06 00 LD B,00h ; bc is displacement into table

669/ A45D : 09 ADD HL,BC ; address to char

670/ A45E : 7E LD A,(HL) ; get translation char

671/ A45F : FE F0 CP 0F0h ; display code for space?

672/ A461 : 20 02 JR NZ,lC7B5 ; no, continue

673/ A463 : E6 20 AND 20h ; yes, translate to 20h

674/ A465 : D1 lC7B5: POP DE ; restore callers regs

675/ A466 : E1 POP HL

676/ A467 : C1 POP BC

677/ A468 : C9 RET ; goback to caller

678/ A469 :

679/ A469 : ; compute contents of HL to decimal and print up to 5

680/ A469 : ; chars without preceding nulls

681/ A469 :

682/ A469 : D5 HLtoASC: push de ; save callers reg

683/ A46A : 01 F0 A0 ld bc,ascwork ; workarea for me

684/ A46D : 11 10 27 ld de,10000 ; 10 exp 4

685/ A470 : CD A0 A4 call hltoa30 ; 5th power of 10

686/ A473 : 11 E8 03 ld de,1000 ; 10 exp 3

687/ A476 : CD A0 A4 call hltoa30 ; 4th power of 10

688/ A479 : 11 64 00 ld de,100 ; 10 exp 2

689/ A47C : CD A0 A4 call hltoa30 ; 3rd power of 10

690/ A47F : 11 0A 00 ld de,10 ; 10 exp 1

691/ A482 : CD A0 A4 call hltoa30 ; 2nd power of 10

692/ A485 : 7D ld a,l ;

AS V1.40r8 - Quelle MZ1571.ASM - Seite 13 - 23.8.1998 0:23:26



693/ A486 : F6 30 or '0' ; comp to decimal

694/ A488 : 02 ld (bc),a ; 10 exp 0

695/ A489 : 11 F0 A0 ld de,ascwork

696/ A48C : 06 04 ld b,04h ; max. 4 preceding nulls to skip of 5

697/ A48E : 1A hltoa10: ld a,(de) ; get printable dec. number

698/ A48F : FE 30 cp '0' ; check for dec. 0

699/ A491 : 20 03 jr nz,hltoa20 ; no, go to print remaining numbers

700/ A493 : 13 inc de

701/ A494 : 10 F8 djnz hltoa10 ; yes, skip preceding 0

702/ A496 : 04 hltoa20: inc b ; adjust b

703/ A497 : 1A hltoa25: ld a,(de) ; get number (0-9)

704/ A498 : CD 12 00 call prnt ; print/plot number

705/ A49B : 13 inc de

706/ A49C : 10 F9 djnz hltoa25 ; do next number

707/ A49E : D1 pop de ; end, restore callers reg

708/ A49F : C9 ret ; goback to caller

709/ A4A0 :

710/ A4A0 : 3E FF hltoa30: ld a,0ffh ; init counter to ffh+1=00

711/ A4A2 : 3C hltoa35: inc a ; count up

712/ A4A3 : B7 or a ; clear carry

713/ A4A4 : ED 52 sbc hl,de ; subtract until negative value

714/ A4A6 : 30 FA jr nc,hltoa35 ; value is positive

715/ A4A8 : 19 add hl,de ; make positive

716/ A4A9 : F6 30 or '0' ; make ascii

717/ A4AB : 02 ld (bc),a ; store to workarea

718/ A4AC : 03 inc bc ; next free address in workarea

719/ A4AD : C9 ret ; goback to caller

720/ A4AE :

721/ A4AE : ; wait on any key

722/ A4AE :

723/ A4AE : C5 WaitKey: push bc ; save callers reg

724/ A4AF : CD 50 0A waitK010: call SWEP ; keyboard swep

725/ A4B2 : 78 ld a,b ; any key?

726/ A4B3 : E6 BF and 0bfh ; turn off d6=shift, brk only

727/ A4B5 : 28 F8 jr z,waitk010 ; no, wait

728/ A4B7 : 78 ld a,b

729/ A4B8 : C1 pop bc ; yes, ok, restore callers reg

730/ A4B9 : FE 88 cp 88h ; test brk key+shift

731/ A4BB : C9 ret ; done

732/ A4BC :

733/ A4BC :

734/ A4BC : ; ErrorChk: analyse errors and print dependent error message

735/ A4BC : ;

736/ A4BC : ; program logic:

737/ A4BC : ; save af (contents of accu and carry flag)

738/ A4BC : ; call errchk40 (prints err.msg load-/save-/verify-error first if any)

739/ A4BC : ; restore af (contents of accu and carry on entry)

740/ A4BC : ; if carry

741/ A4BC : ; if a=0 (accu on entry)

742/ A4BC : ; print "Break"

743/ A4BC : ; endif

744/ A4BC : ; endif

745/ A4BC : ;

746/ A4BC : ;

747/ A4BC : F5 ErrorChk: push af ; save carry flag

748/ A4BD : CD CF A4 call Errchk40 ; if carry output msg on error

749/ A4C0 : F1 errchk20: pop af ; get back contents of accu and carry

750/ A4C1 : D0 ret nc ; goback, done (no break)

751/ A4C2 : A7 and a

752/ A4C3 : C0 ret nz ; goback, if brk (accu=1bh)

AS V1.40r8 - Quelle MZ1571.ASM - Seite 14 - 23.8.1998 0:23:26



753/ A4C4 : 11 5E A0 ld de,break ; address to msg

754/ A4C7 : CD 15 00 errchk30: call msg ; print msg

755/ A4CA : CD 06 00 call letnl

756/ A4CD : 37 scf ; set carry (brk info)

757/ A4CE : C9 ret ; goback

758/ A4CF :

759/ A4CF : ; ErrChk40: print load/save/verify error msg

760/ A4CF : ; program logic:

761/ A4CF : ; if no carry

762/ A4CF : ; turn off eof bit6 of st (set at time of eof, not at time of brk)

763/ A4CF : ; if accu=0

764/ A4CF : ; return

765/ A4CF : ; endif

766/ A4CF : ; endif

767/ A4CF : ; if lvflag=01h

768/ A4CF : ; print "Verifying error"

769/ A4CF : ; else if lvflag=02h

770/ A4CF : ; print "Save error"

771/ A4CF : ; else print "Load error" (lvflag=00h)

772/ A4CF : ; endif

773/ A4CF : ; endif

774/ A4CF : ;

775/ A4CF : ;

776/ A4CF : 38 06 errchk40: jr c,errchk50 ; no eof

777/ A4D1 : 3A DB A0 ld a,(ST)

778/ A4D4 : E6 BF and 0bfh ; turn off eof bit

779/ A4D6 : C8 ret z ; if eof bit only goback

780/ A4D7 : 3A DC A0 errchk50: ld a,(LVFlag) ; get flag

781/ A4DA : FE 01 cp 01h ; verify error?

782/ A4DC : 20 07 jr nz,errchk60 ; no

783/ A4DE : 11 64 A0 ld de,veriferr ; yes, address to verify error msg

784/ A4E1 : CD C7 A4 errchk55: call errchk30 ; print error msg

785/ A4E4 : C9 ret ; goback to caller

786/ A4E5 :

787/ A4E5 : FE 02 errchk60: cp 02h ; save error?

788/ A4E7 : 20 05 jr nz,errchk70 ; no

789/ A4E9 : 11 74 A0 ld de,saveerr ; address to save error msg

790/ A4EC : 18 F3 jr errchk55 ; go to print

791/ A4EE :

792/ A4EE : 11 7F A0 errchk70: ld de,loaderr ; address to load error msg

793/ A4F1 : 18 EE jr errchk55 ; go to print

794/ A4F3 :

795/ A4F3 :

796/ A4F3 : ; send Talk/Listen to floppy

797/ A4F3 :

798/ A4F3 : ed09:

799/ A4F3 : Talk:

800/ A4F3 : F6 40 sentTalk: or 40h ; set talker bit

801/ A4F5 : 18 02 jr ed11

802/ A4F7 :

803/ A4F7 : F6 20 Listen: or 20h ; set listener bit

804/ A4F9 : F5 ed11: push af ; save for further process

805/ A4FA : 3A DD A0 ld a,(iecflag) ;

806/ A4FD : CB 7F bit 7,a ; outputting end? (counter=0?)

807/ A4FF : 28 1B jr z,ed20 ; yes

808/ A501 : 37 scf

809/ A502 : 3A DF A0 ld a,(sta)

810/ A505 : 1F rra

811/ A506 : 32 DF A0 ld (sta),a

812/ A509 : CD 3C A5 call ed40 ; put byte on iec bus

AS V1.40r8 - Quelle MZ1571.ASM - Seite 15 - 23.8.1998 0:23:26



813/ A50C : 3A DD A0 ld a,(iecflag)

814/ A50F : CB 3F srl a ; turns off bit 7

815/ A511 : 32 DD A0 ld (iecflag),a

816/ A514 : 3A DF A0 ld a,(sta)

817/ A517 : CB 3F srl a ; turns off bit 7

818/ A519 : 32 DF A0 ld (sta),a

819/ A51C : F1 ed20: pop af ; byte to put on iec bus

820/ A51D : 32 DE A0 ld (iecbuf),a ; put command to iec buffer

821/ A520 : CD 95 A6 call ee97 ; set data high

822/ A523 : 3A 08 E0 ld a,(le008) ; port LS367

823/ A526 : CB 5F bit 3,a ; data low?

824/ A528 : CC 83 A6 call z,ee85 ; yes, set clk high

825/ A52B : 3A 00 E0 ld a,(le000) ; 8255-port A

826/ A52E : F6 10 or 10h

827/ A530 : 32 00 E0 ld (le000),a ; set atn low (8255-port A)

828/ A533 : CD 8C A6 ed36: call ee8e ; set clk low (atn=clk=lo=listen)

829/ A536 : CD 95 A6 call ee97 ; set data high

830/ A539 : CD B6 A6 call eeb3 ; wait 1ms

831/ A53C : CD 95 A6 ed40: call ee97 ; set data high

832/ A53F : CD A7 A6 call eea9 ; get state of data line

833/ A542 : DA A5 A5 jp c,edad ; error, data is high (no dev. pres.)

834/ A545 : CD 83 A6 call ee85 ; data line low, set clk high

835/ A548 : 3A DF A0 ld a,(sta)

836/ A54B : CB 7F bit 7,a ; floppy status

837/ A54D : 28 0A jr z,ed5a

838/ A54F : CD A7 A6 ed50: call eea9 ; get state of data

839/ A552 : 30 FB jr nc,ed50 ; wait for data high

840/ A554 : CD A7 A6 ed55: call eea9 ; get state of data line

841/ A557 : 38 FB jr c,ed55 ; wait for data low

842/ A559 : CD A7 A6 ed5a: call eea9 ; get state of data

843/ A55C : 30 FB jr nc,ed5a ; wait for data high

844/ A55E : CD 8C A6 call ee8e ; set clk low

845/ A561 : 3E 08 ld a,08h

846/ A563 : 32 E0 A0 ld (bitcnt),a ; 8 bits

847/ A566 : 3A 08 E0 ed66: ld a,(le008) ; port LS367

848/ A569 : 47 ld b,a

849/ A56A : 3A 08 E0 ld a,(le008) ; port LS367

850/ A56D : B8 cp b

851/ A56E : 20 F6 jr nz,ed66 ; wait for stable state of iec bus

852/ A570 : CB 5F bit 3,a

853/ A572 : 28 34 jr z,edb0 ; if data low, error (timeout)

854/ A574 : 3A DE A0 ld a,(iecbuf)

855/ A577 : 1F rra

856/ A578 : 32 DE A0 ld (iecbuf),a

857/ A57B : 38 05 jr c,dath ; buffer bit is on

858/ A57D : CD 9E A6 call eea0 ; buffer bit is off, set data low

859/ A580 : 18 03 jr clkh

860/ A582 :

861/ A582 : CD 95 A6 dath: call ee97 ; set data high

862/ A585 : CD 83 A6 clkh: call ee85 ; set clk hi (data bit ready)

863/ A588 : CD 8C A6 call ee8e ; set clk low

864/ A58B : CD 95 A6 call ee97 ; set data high

865/ A58E : 00 nop ; wait 4 nop's

866/ A58F : 00 nop

867/ A590 : 00 nop

868/ A591 : 00 nop

869/ A592 : 21 E0 A0 ld hl,bitcnt

870/ A595 : 35 dec (hl) ; bit count - 1

871/ A596 : 20 CE jr nz,ed66 ; if not 8 bits sent process again

872/ A598 : 16 FB ld d,0fbh ; timer

AS V1.40r8 - Quelle MZ1571.ASM - Seite 16 - 23.8.1998 0:23:26



873/ A59A : CD A7 A6 ed9f: call eea9 ; get state of data line

874/ A59D : CB 5F bit 3,a

875/ A59F : C8 ret z ; if data low, goback

876/ A5A0 : 15 dec d ; timer - 1

877/ A5A1 : 20 F7 jr nz,ed9f

878/ A5A3 : 18 03 jr edb0 ; error, time out, no ack

879/ A5A5 :

880/ A5A5 : ; set state to 80h/03h

881/ A5A5 :

882/ A5A5 : 3E 80 edad: ld a,80h ; status device not present

883/ A5A7 : 21 db 21h ; dummy instruction ld hl,3e03h

884/ A5A8 : 3E 03 edb0: ld a,03h ; status time out

885/ A5AA : CD 75 A8 edb2: call fe1c ; set status

886/ A5AD : A7 and a ; set/reset flags

887/ A5AE : 18 55 jr ee03 ; jump in unlisten

888/ A5B0 :

889/ A5B0 : ; send sec.address just behind sent of listen

890/ A5B0 :

891/ A5B0 : 32 DE A0 edb9: ld (iecbuf),a ; store sec.address

892/ A5B3 : CD 33 A5 call ed36 ; put it on iec bus

893/ A5B6 : 3A 00 E0 edbe: ld a,(le000) ; 8255-port A

894/ A5B9 : E6 EF and 0efh

895/ A5BB : 32 00 E0 ld (le000),a ; set atn high

896/ A5BE : C9 ret ; goback

897/ A5BF :

898/ A5BF : ; send sec.address just behind sent of talk

899/ A5BF :

900/ A5BF : edc7:

901/ A5BF : 32 DE A0 sentsadr: ld (iecbuf),a ; store sec.address

902/ A5C2 : CD 33 A5 call ed36 ; put it on iec bus

903/ A5C5 : CD 9E A6 call eea0 ; set data low

904/ A5C8 : CD B6 A5 call edbe ; set atn high

905/ A5CB : CD 83 A6 call ee85 ; set clk high

906/ A5CE : CD A7 A6 edd6: call eea9 ; get state of clk

907/ A5D1 : CB 4F bit 1,a ; test state of clk

908/ A5D3 : 28 F9 jr z,edd6 ; wait on clk high

909/ A5D5 : C9 ret ; goback

910/ A5D6 :

911/ A5D6 : ; IECOUT put 1 char on iec bus

912/ A5D6 :

913/ A5D6 : F5 eddd: push af ; save char to put on iec bus

914/ A5D7 : 3A DD A0 ld a,(iecflag) ;

915/ A5DA : CB 7F bit 7,a

916/ A5DC : 20 09 jr nz,ede6

917/ A5DE : 37 scf

918/ A5DF : ; ld a,(iecflag)

919/ A5DF : 1F rra

920/ A5E0 : 32 DD A0 ld (iecflag),a

921/ A5E3 : CB 7F bit 7,a

922/ A5E5 : 20 05 jr nz,edeb

923/ A5E7 : F1 ede6: pop af ; get callers reg

924/ A5E8 : F5 push af ; save

925/ A5E9 : CD 3C A5 call ed40 ; put byte out

926/ A5EC : F1 edeb: pop af ; restore char to output to bus

927/ A5ED : 32 DE A0 ld (iecbuf),a ; store in iec buffer

928/ A5F0 : A7 and a ; reset carry

929/ A5F1 : C9 ret ; goback

930/ A5F2 :

931/ A5F2 : ; send untalk

932/ A5F2 :

AS V1.40r8 - Quelle MZ1571.ASM - Seite 17 - 23.8.1998 0:23:26



933/ A5F2 : CD 8C A6 edef: call ee8e ; set clk low

934/ A5F5 : 3A 00 E0 ld a,(le000) ; 8255-port A

935/ A5F8 : F6 10 or 10h

936/ A5FA : 32 00 E0 ld (le000),a ; set atn low

937/ A5FD : 3E 5F ld a,5fh ; command untalk

938/ A5FF : 21 db 21h ; dummy instr. ld hl,3e3fh

939/ A600 : 3E 3F unlisten: ld a,3fh ; command unlisten

940/ A602 : CD F9 A4 call ed11 ; put it on iec bus

941/ A605 : CD B6 A5 ee03: call edbe ; set atn high

942/ A608 : 06 0A ee06: ld b,0ah

943/ A60A : 05 ee09: dec b

944/ A60B : 20 FD jr nz,ee09 ; wait 40µs

945/ A60D : CD 83 A6 call ee85 ; set clk high

946/ A610 : C3 95 A6 jp ee97 ; set data high

947/ A613 :

948/ A613 : ; IECIN get 1 char from iec bus

949/ A613 :

950/ A613 : ee13:

951/ A613 : AF iecin: xor a

952/ A614 : 32 E0 A0 ld (bitcnt),a ; init bit counter

953/ A617 : CD 83 A6 call ee85 ; set clk high

954/ A61A : CD A7 A6 ee1b: call eea9 ; get state of clk

955/ A61D : CB 4F bit 1,a

956/ A61F : 28 F9 jr z,ee1b ; wait on clk high

957/ A621 : CD 95 A6 ee20: call ee97 ; set data high

958/ A624 : 16 FF ld d,0ffh ; init timer

959/ A626 : CD A7 A6 ee37: call EEA9 ; get clk bit from carry flag

960/ A629 : CB 4F bit 1,a ; test clk bit

961/ A62B : 28 1F jr z,ee56 ; wait on clk lo (then valid databit)

962/ A62D : 15 dec d ; timer - 1

963/ A62E : 20 F6 jr nz,ee37 ; loop

964/ A630 : 3A E0 A0 ld a,(bitcnt) ; get bit counter

965/ A633 : A7 and a ; test for zero

966/ A634 : 28 05 jr z,ee47 ; no bits received, force eof (?)

967/ A636 : 3E 02 ld a,02h ; timeout

968/ A638 : C3 AA A5 jp edb2 ; set status

969/ A63B :

970/ A63B : CD 9E A6 ee47: call eea0 ; set data low

971/ A63E : CD 83 A6 call ee85 ; set clk hi

972/ A641 : 3E 40 ld a,40h ; set state to eof

973/ A643 : CD 75 A8 call fe1c ; do it

974/ A646 : 21 E0 A0 ld hl,bitcnt ; when shall this condition occur???

975/ A649 : 34 inc (hl) ; increment bit counter

976/ A64A : 20 D5 jr nz,ee20 ; wait until bit counter equals zero

977/ A64C : ; test for programmed loop or bug (no inc to bitcnt in this address range)

978/ A64C : 3E 08 ee56: ld a,08h

979/ A64E : 32 E0 A0 ld (bitcnt),a ; set bit count

980/ A651 : CD A7 A6 ee5a: call eea9 ; get state of clk

981/ A654 : CB 4F bit 1,a

982/ A656 : 28 F9 jr z,ee5a ; wait on clk high

983/ A658 : E6 08 and 08h ; 1st valid bit arrives, isolate data

984/ A65A : 28 01 jr z,ee65 ; data bit is zero, carry=0

985/ A65C : 37 scf ; data bit is one, carry=1

986/ A65D :

987/ A65D : ; test, no usage?

988/ A65D : 3A EE A0 ee65: ld a,(zwispei) ;

989/ A660 : 1F rra

990/ A661 : 32 EE A0 ld (zwispei),a

991/ A664 : CD A7 A6 ee67: call eea9 ; get state of clk

992/ A667 : CB 4F bit 1,a

AS V1.40r8 - Quelle MZ1571.ASM - Seite 18 - 23.8.1998 0:23:26



993/ A669 : 20 F9 jr nz,ee67 ; wait on clk low

994/ A66B : 21 E0 A0 ld hl,bitcnt

995/ A66E : 35 dec (hl) ; bit count - 1

996/ A66F : 20 E0 jr nz,ee5a ; loop until 8 bits received

997/ A671 : CD 9E A6 call eea0 ; byte complete, set data low

998/ A674 : 3A DB A0 ld a,(st)

999/ A677 : CB 77 bit 6,a ; eof?

1000/ A679 : 28 03 jr z,ee80 ; yes, dont wait and...

1001/ A67B : CD 08 A6 call ee06 ; wait 40µs then set clk and data hi

1002/ A67E : 3A EE A0 ee80: ld a,(zwispei) ; ????

1003/ A681 : A7 and a ; reset carry

1004/ A682 : C9 ret ; goback

1005/ A683 :

1006/ A683 : ; set clk line high

1007/ A683 :

1008/ A683 : ee85:

1009/ A683 : 3A 00 E0 clkhi: ld a,(le000) ; 8255-port A

1010/ A686 : E6 DF and 0dfh ; turn off bit 5 (clk high)

1011/ A688 : 32 00 E0 ld (le000),a

1012/ A68B : C9 ret ; goback

1013/ A68C :

1014/ A68C : ; set clk line low

1015/ A68C :

1016/ A68C : ee8e:

1017/ A68C : 3A 00 E0 clklo: ld a,(le000) ; 8255-port A

1018/ A68F : F6 20 or 20h ; set bit 5 (clk low)

1019/ A691 : 32 00 E0 ld (le000),a

1020/ A694 : C9 ret ; goback

1021/ A695 :

1022/ A695 : ; set data high

1023/ A695 :

1024/ A695 : ee97:

1025/ A695 : 3A 00 E0 datahi: ld a,(le000) ; 8255-port A

1026/ A698 : E6 BF and 0bfh ; turn off bit 6 (data high)

1027/ A69A : 32 00 E0 ld (le000),a

1028/ A69D : C9 ret ; goback

1029/ A69E :

1030/ A69E : ; set data low

1031/ A69E :

1032/ A69E : eea0:

1033/ A69E : 3A 00 E0 datalo: ld a,(le000) ; 8255-port A

1034/ A6A1 : F6 40 or 40h ; set bit 6 (data low)

1035/ A6A3 : 32 00 E0 ld (le000),a

1036/ A6A6 : C9 ret ; goback

1037/ A6A7 :

1038/ A6A7 : ; get state of all input lines and move bit of data to carry flag

1039/ A6A7 :

1040/ A6A7 : eea9:

1041/ A6A7 : 3A 08 E0 getbit: ld a,(le008) ; Port LS367

1042/ A6AA : 47 ld b,a

1043/ A6AB : 3A 08 E0 ld a,(le008)

1044/ A6AE : B8 cp b

1045/ A6AF : 20 F6 jr nz,eea9 ; wait for stable iec bus

1046/ A6B1 : CB 5F bit 3,a ; test bit 3

1047/ A6B3 : C8 ret z ; bit3=0, carry=0

1048/ A6B4 : 37 scf ; bit3=1, carry=1

1049/ A6B5 : C9 ret ; goback

1050/ A6B6 :

1051/ A6B6 : ; wait for 1ms

1052/ A6B6 :

AS V1.40r8 - Quelle MZ1571.ASM - Seite 19 - 23.8.1998 0:23:26



1053/ A6B6 : eeb3:

1054/ A6B6 : 06 FF wait1ms: ld b,0ffh ; init loop counter

1055/ A6B8 : 05 eeb6: dec b ; b=b-1

1056/ A6B9 : C2 B8 A6 jp nz,eeb6 ; loop until b=0

1057/ A6BC : C9 ret ; goback

1058/ A6BD :

1059/ A6BD :

1060/ A6BD : ; IECOPEN

1061/ A6BD :

1062/ A6BD : f3d5:

1063/ A6BD : 3A E4 A0 IECOPEN: ld a,(secadr)

1064/ A6C0 : CB 7F bit 7,a ; secondary address?

1065/ A6C2 : 28 02 jr z,f3d9 ; yes, continue open

1066/ A6C4 : A7 and a ; no, primary address

1067/ A6C5 : C9 ret ; goback

1068/ A6C6 :

1069/ A6C6 : 3A E3 A0 f3d9: ld a,(filelen) ; test length of file name

1070/ A6C9 : A7 and A

1071/ A6CA : C8 RET Z ; if no filename goback

1072/ A6CB : AF XOR A

1073/ A6CC : 32 DB A0 LD (ST),a ; clear state

1074/ A6CF : 3A E5 A0 ld a,(gernr) ; get unit address (mormally icon_cool.gif

1075/ A6D2 : CD F7 A4 call listen ; send listen to this unit

1076/ A6D5 : 3A E4 A0 ld a,(secadr)

1077/ A6D8 : F6 F0 or 0f0h ; set open bits on

1078/ A6DA : CD B0 A5 call edb9 ; send open cmd with sec. address

1079/ A6DD : 3A DB A0 ld a,(ST) ;

1080/ A6E0 : CB 7F bit 7,a ; device ok?

1081/ A6E2 : 28 03 jr z,f3f6 ; yes

1082/ A6E4 : C3 55 A8 jp f707 ; no, error

1083/ A6E7 :

1084/ A6E7 : 3A E3 A0 f3f6: ld a,(filelen) ; test length of file name

1085/ A6EA : A7 and a

1086/ A6EB : CA 37 A8 jp z,f654 ; jump to unlisten

1087/ A6EE : 0E 00 ld c,00h ; init loop count

1088/ A6F0 : 21 9B A8 ld hl,filename+11 ; set hl to 1st char of file name

1089/ A6F3 : 79 iecope30: ld a,c

1090/ A6F4 : 32 EC A0 ld (asave),a ; save loop count

1091/ A6F7 : 22 ED A0 ld (hlsave),hl ; save current addr. of file name

1092/ A6FA : 7E ld a,(hl) ; get current char of file name

1093/ A6FB : CD D6 A5 call eddd ; IECOUT 1 char put on iec bus

1094/ A6FE : 3A EC A0 ld a,(asave)

1095/ A701 : 4F ld c,a ; restore c with loop count

1096/ A702 : 2A ED A0 ld hl,(hlsave) ; restore current address

1097/ A705 : 23 inc hl ; next address of char to send

1098/ A706 : 0C inc c ; inc loop count

1099/ A707 : 3A E3 A0 ld a,(filelen)

1100/ A70A : B9 cp c ; test loop count = length?

1101/ A70B : 20 E6 jr nz,iecope30 ; no, continue

1102/ A70D : C3 37 A8 jp f654 ; yes, send unlisten

1103/ A710 :

1104/ A710 : ; IECLOAD load/verify a file (secondary address 0)

1105/ A710 :

1106/ A710 : f4b8:

1107/ A710 : 3A E3 A0 IECLOAD: ld a,(filelen)

1108/ A713 : A7 and a

1109/ A714 : CA 65 A8 jp z,f710 ; error, no file name given

1110/ A717 : 3A E4 A0 ld a,(secadr)

1111/ A71A : 32 EF A0 ld (svsecadr),a ; save sec. addr. for futher use

1112/ A71D : CD A3 A7 call f5af ; put msg "searching for..."

AS V1.40r8 - Quelle MZ1571.ASM - Seite 20 - 23.8.1998 0:23:26



1113/ A720 : 3E 60 ld a,60h ; sec. addr. 0 listen and talk

1114/ A722 : 32 E4 A0 ld (secadr),a

1115/ A725 : CD BD A6 call iecopen ; open file

1116/ A728 : 3A E5 A0 ld a,(gernr)

1117/ A72B : CD F3 A4 call talk ; force talking of (gernr)

1118/ A72E : 3A E4 A0 ld a,(secadr)

1119/ A731 : CD BF A5 call edc7 ; submit sec. addr.

1120/ A734 : CD 13 A6 call ee13 ; get low byte (IECIN) of load addr.

1121/ A737 : 32 E1 A0 ld (endptr),a ; save

1122/ A73A : 3A DB A0 ld a,(st) ; state of floppy drive

1123/ A73D : CB 3F srl a ; turn off bit 7 and bit 6 too

1124/ A73F : CB 3F srl a ;

1125/ A741 : 38 57 jr c,f530 ; if bit 6 was on jump

1126/ A743 : CD 13 A6 call ee13 ; get high byte of load address

1127/ A746 : 32 E2 A0 ld (endptr+1),a ; save, address is complete

1128/ A749 : 3A EF A0 mdfcmd02: ld a,(svsecadr) ; get back sec. addr.

1129/ A74C : A7 and a

1130/ A74D : 20 0C jr nz,f4f0 ; if zero take user's load address

1131/ A74F : 3A E8 A0 ld a,(adrload) ; see load routine for futher info

1132/ A752 : 32 E1 A0 ld (endptr),a ; not used if called by verify

1133/ A755 : 3A E9 A0 ld a,(adrload+1)

1134/ A758 : 32 E2 A0 ld (endptr+1),a

1135/ A75B : CD BE A7 f4f0: call f5d2 ; msg loading/verifying

1136/ A75E : 3A DB A0 f4f3: ld a,(st)

1137/ A761 : E6 FD and 0fdh ; clear timeout

1138/ A763 : 32 DB A0 LD (st),a

1139/ A766 : CD 13 A6 call ee13 ; get byte from IEC bus

1140/ A769 : 4F ld c,a ; save byte

1141/ A76A : 3A DB A0 ld a,(st)

1142/ A76D : CB 3F srl a

1143/ A76F : CB 3F srl a

1144/ A771 : 38 EB jr c,f4f3

1145/ A773 : 3A DC A0 ld a,(lvflag) ; test for load or verify

1146/ A776 : A7 and a

1147/ A777 : 2A E1 A0 ld hl,(endptr) ; ptr to current address in storage

1148/ A77A : 79 ld a,c ; restore byte read

1149/ A77B : 28 0B jr z,f51c ; jump if load active

1150/ A77D : 7E ld a,(hl) ; verify active, get byte of storage

1151/ A77E : B9 cp c ; verify byte read and storage

1152/ A77F : 28 08 jr z,f51e ; junp if okay

1153/ A781 : 3E 10 ld a,10h ; not ok

1154/ A783 : CD 75 A8 call fe1c ; set state to verify error

1155/ A786 : 18 01 jr f51e ; continue

1156/ A788 :

1157/ A788 : 77 f51c: ld (hl),a ; load byte read to starage

1158/ A789 : 23 f51e: inc hl

1159/ A78A : 22 E1 A0 ld (endptr),hl ; ptr to next

1160/ A78D : 3A DB A0 ld a,(st)

1161/ A790 : CB 77 bit 6,a ; eof?

1162/ A792 : 28 CA jr z,f4f3 ; no

1163/ A794 : CD F2 A5 f528: call edef ; yes, send untalk

1164/ A797 : CD 20 A8 call iecclose ; close

1165/ A79A : DA 45 A8 f530: jp c,f704 ; error, (file not found?)

1166/ A79D : A7 and a ; set/reset flags

1167/ A79E : ED 5B E1 A0 ld de,(endptr)

1168/ A7A2 : C9 ret ; goback

1169/ A7A3 :

1170/ A7A3 : ; put msg "searching for..." on screen

1171/ A7A3 :

1172/ A7A3 : 11 8A A0 f5af: ld de,searchfo ; address this msg

AS V1.40r8 - Quelle MZ1571.ASM - Seite 21 - 23.8.1998 0:23:26



1173/ A7A6 : CD 15 00 call msg ; output this msg

1174/ A7A9 : 3A E3 A0 f5c1: ld a,(filelen) ; get length of filename

1175/ A7AC : A7 and a

1176/ A7AD : C8 ret z ; no filename

1177/ A7AE : 47 ld b,a ; b is counter

1178/ A7AF : 21 9B A8 ld hl,filename+11 ; address of filename

1179/ A7B2 : 7E f5c7: ld a,(hl) ; get filename char

1180/ A7B3 : CD 12 00 call prnt ; output char to screen

1181/ A7B6 : 23 inc hl ; point to next

1182/ A7B7 : 05 dec b ; length - 1

1183/ A7B8 : 20 F8 jr nz,f5c7 ; continue if not all

1184/ A7BA : CD 06 00 call letnl ; set cursor on next line on screen

1185/ A7BD : C9 ret ; goback

1186/ A7BE :

1187/ A7BE : ; put msg "Loading..." on screen

1188/ A7BE :

1189/ A7BE : 11 99 A0 f5d2: ld de,loading ; address to msg

1190/ A7C1 : 3A DC A0 ld a,(lvflag) ; get Load/verify flag

1191/ A7C4 : A7 and a

1192/ A7C5 : 28 03 jr z,f5da ; 00 means load active

1193/ A7C7 : 11 A2 A0 ld de,veryfing ; 01 means verify,address to this msg

1194/ A7CA : CD 15 00 f5da: call msg ; put msg on screen

1195/ A7CD : CD A9 A7 call f5c1 ; put filename on screen

1196/ A7D0 : C9 ret ; goback

1197/ A7D1 :

1198/ A7D1 : ; IECSTORE puts header & file on IEC bus (secondary address 1)

1199/ A7D1 :

1200/ A7D1 : f5fa:

1201/ A7D1 : 3A E3 A0 IECSTORE: ld a,(filelen) ; get length of filename

1202/ A7D4 : A7 and a

1203/ A7D5 : CA 65 A8 jp z,f710 ; missing filename if zero

1204/ A7D8 : 3E 61 ld a,61h ; sec. addr 1 listener and talker

1205/ A7DA : 32 E4 A0 ld (secadr),a

1206/ A7DD : CD BD A6 call iecopen ; open new file

1207/ A7E0 : CD 3C A8 call f68f ; msg "Saving.."

1208/ A7E3 : 3A E5 A0 ld a,(gernr)

1209/ A7E6 : CD F7 A4 call listen ; force listen for (gernr)

1210/ A7E9 : 3A E4 A0 ld a,(secadr)

1211/ A7EC : CD B0 A5 call edb9 ; send sec. addr.

1212/ A7EF : ED 5B E6 A0 ld de,(iostrt)

1213/ A7F3 : ED 53 EA A0 ld (biostrt),de ; save

1214/ A7F7 : 3A EA A0 ld a,(biostrt) ; low byte of begin

1215/ A7FA : CD D6 A5 call eddd ; put it on bus

1216/ A7FD : 3A EB A0 ld a,(biostrt+1) ; high byte of begin

1217/ A800 : CD D6 A5 call eddd ; put it on bus

1218/ A803 : A7 f624: and a

1219/ A804 : 2A E1 A0 ld hl,(endptr) ; ptr to end

1220/ A807 : ED 5B EA A0 ld de,(biostrt) ; current address of storage

1221/ A80B : ED 52 sbc hl,de

1222/ A80D : 38 0E jr c,f63f ; stop if negative

1223/ A80F : 1A ld a,(de) ; get next byte

1224/ A810 : CD D6 A5 call eddd ; output to iec bus

1225/ A813 : 21 EA A0 f63a: ld hl,biostrt ; save max. to ffffh

1226/ A816 : 34 inc (hl)

1227/ A817 : 20 EA jr nz,f624 ; continue if low byte not zero

1228/ A819 : 23 inc hl

1229/ A81A : 34 inc (hl)

1230/ A81B : 20 E6 jr nz,f624 ; continue if high byte not zero

1231/ A81D : CD 00 A6 f63f: call unlisten ; send unlisten

1232/ A820 : f642:

AS V1.40r8 - Quelle MZ1571.ASM - Seite 22 - 23.8.1998 0:23:26



1233/ A820 : 3A E4 A0 iecclose: ld a,(secadr)

1234/ A823 : CB 7F bit 7,a ; test on secondary address

1235/ A825 : 20 13 jr nz,f657 ; no, primary address, done

1236/ A827 : 3A E5 A0 ld a,(gernr)

1237/ A82A : CD F7 A4 call listen ; force listen for (gernr)

1238/ A82D : 3A E4 A0 ld a,(secadr)

1239/ A830 : E6 EF and 0efh

1240/ A832 : F6 E0 or 0e0h

1241/ A834 : CD B0 A5 call edb9 ; close sec. addr. 1

1242/ A837 : CD 00 A6 f654: call unlisten ; send unlisten

1243/ A83A : A7 f657: and a ; set/reset flags

1244/ A83B : C9 ret ; goback

1245/ A83C :

1246/ A83C : ; put msg "Saving..." on screen

1247/ A83C :

1248/ A83C : 11 AD A0 f68f: ld de,saving ; address to msg

1249/ A83F : CD 15 00 call msg ; output msg

1250/ A842 : C3 A9 A7 jp f5c1 ; add filename to msg

1251/ A845 :

1252/ A845 : ; put msg "File not found" on screen

1253/ A845 :

1254/ A845 : 11 B5 A0 f704: ld de,filenfnd ; address to msg

1255/ A848 : CD C7 A4 call errchk30 ; output msg

1256/ A84B : CD BC A4 call ErrorChk

1257/ A84E : ED 7B D9 A0 ld sp,(stckptr) ; force stop on error

1258/ A852 : C3 15 A2 jp GetErSta

1259/ A855 :

1260/ A855 : ; put msg "device not present" on screen

1261/ A855 :

1262/ A855 : 11 4B A0 f707: ld de,devnpres ; address to msg

1263/ A858 : CD C7 A4 call errchk30 ; output msg

1264/ A85B : CD BC A4 call ErrorChk

1265/ A85E : ED 7B D9 A0 ld sp,(stckptr) ; force stop on error

1266/ A862 : C3 F5 A0 jp start

1267/ A865 :

1268/ A865 : ; put msg "Missing filename" on screen

1269/ A865 :

1270/ A865 : 11 C4 A0 f710: ld de,namemiss ; address to msg

1271/ A868 : CD C7 A4 call errchk30 ; output msg

1272/ A86B : CD BC A4 call ErrorChk

1273/ A86E : ED 7B D9 A0 ld sp,(stckptr) ; force stop on error

1274/ A872 : C3 F5 A0 jp start ;

1275/ A875 :

1276/ A875 : ; set state

1277/ A875 :

1278/ A875 : 47 fe1c: ld b,a

1279/ A876 : 3A DB A0 ld a,(st)

1280/ A879 : B0 or b

1281/ A87A : 32 DB A0 ld (st),a

1282/ A87D : C9 ret

1283/ A87E :

1284/ A87E : ; end of program, goback to monitor

1285/ A87E : CD 06 00 intbrk: call letnl

1286/ A881 : 11 5E A0 ld de,break

1287/ A884 : CD 15 00 call msg

1288/ A887 : CD 06 00 call letnl

1289/ A88A : 31 F0 10 intrpt: ld sp,10f0h ; init stackpointer

1290/ A88D : C3 AD 00 jp st1 ; goback to Monitor-ROM

1291/ A890 :

1292/ A890 :

AS V1.40r8 - Quelle MZ1571.ASM - Seite 23 - 23.8.1998 0:23:26


mz1571.zip

  • Like 1
Link to comment
Share on other sites

Apparently, I am not the first person to come up with this idea!

 

http://8bit.yarek.pl/interface/zx81.zx1541/

 

ZX1541 by Luis Claudio Grosso
Interface that connects Timex Sinclair 1500 (in Argentina known as Czerweny CZ1500) or Sinclair ZX81 with Commodore 1541 disk drive.
Technical description.
The interface has two memory chips:
- 62256 SRAM (32kB),
- 28C64 EEPROM (8kB).
The logic is made of following chips:
- 74*174 latches 6 bits of data (port #BF),
- 74*365 allows to read 6 bits of data (port #BF),
- 74*139 decodes memory control signals,
- 74*32 4×OR decodes port address and memory signals,
- 74*06 6×NOT open collector drives IEC lines and LEDs.
Beside some transistors and resistors are used to make simple gates, and 8×1N4148 diodes to protect IEC lines.
1. The port address is decoded on OR gate (74*32) from /IORQ and A6, exactly as in original design. The product is called
/BF signal, what means #BF (#xxBF) address. Other addresses with A6=0 are possible, but not recommended.
2. /BF signal is used directly to control 74*366 buffer together with /RD signal (74*365 has internal OR gate).
Second OR gate (74*32) used on /BF and /WR produces /BFWR signal to latch data into 74*174.
3. 74*174 has reset generator that works only on power-up. This enables the interface and selects memory bank 0. See below.
4. 8kB of 28C64 EEPROM is seen in #2000..#3FFF addresses. The EEPROM is write-protected, when its jumper is open. To update
software close the jumper, then open it again. No extra voltage source is required to reprogram this EEPROM.
5. 32kB of 62256 SRAM is seen in #8000..#BFFF addresses, as two 16kB mutually exclusive banks. Only one of them can be used at a time - which is selected by bit 1 in port #BF. This bit generates MA14 signal that can be read back as bit 1 of #BF port.
6. Both SRAM and EEPROM access are disabled when bit 0 is set in value outed to #BF port. This allows to use other interfaces connected between ZX81 and ZX1541. The bit 0 generates signal called Q0. Q0 is inverted by NOT gate
(74*06), giving /Q0 signal.
7. Memory addresses are decoded by third OR gate (74*32) and half of 74*139 decoder. A13 and A15 lines are ORed to give A13G signal that can be low only for A15=0. For A15=1 is high.
In A14 line is inserted a resistor, this allows the "next" interface connected to through slot to disable ZX1541 memory. The "next" interface can pull up to +5V the DISIN (incoming /ROMCS on edge slot) line by a NPN transistor, exactly like with pure ZX81. The A13G, DISIN (A14 after resistor) and A15 lines are connected to the decoder. This produces three output signals: /000, /001, /10X - see this table (n.c. means not connected or not pulled up by "next" interface):
DISIN A15 A14 A13 A13G /000 /001 /10X - addresses
n.c. 0 0 0 0 0 1 1 - #0000..#1FFF
n.c. 0 0 1 1 1 0 1 - #2000..#3FFF
n.c. 0 1 0 0 1 1 1 - #4000..#5FFF
n.c. 0 1 1 1 1 1 1 - #6000..#7FFF
n.c. 1 0 0 1 1 1 0 - #8000..#9FFF
n.c. 1 0 1 1 1 1 0 - #A000..#BFFF
n.c. 1 1 0 1 1 1 1 - #C000..#DFFF
n.c. 1 1 1 1 1 1 1 - #E000..#FFFF
>+2V x x x x 1 1 1 - #xxxx..#xxxx
9. Interface disables internal ROM decoding of ZX81 by pulling up to +5V the DISOUT line (outgoing /ROMCS on edge slot) with NPN transistor. The transistor is controlled by the fourth OR gate (74*32). So two signals can disconnect
internal ZX81 ROM independently. One of them is DISIN, which is used by "next" interface to disable both ZX1541 and internal ZX81 ROM. The second signal is generated by AND gate made from resistor and open collector inverter (74*06). So
both /000 signal and /Q0 must be in high state to disable the internal ROM of ZX81. /000 is high for all addresses except #0000..#1FFF and /Q0 is high until 1 is written as bit 0 into #BF port. This means, the internal ZX81 ROM is not disabled
only for addresses #0000..#1FFF as long as DISIS is not pulled up by "next" interface ("-" means high impedance, "0r" and "1r" means state set by resistor).
DISIN Q0 /000 /Q0 OR DISOUT - addressess
n.c. 0 0 0r 0 - - #0000..#1FFF
n.c. 0 1 1r 1 1 - #2000..#FFFF
n.c. 1 x 0 0 - - #0000..#FFFF
>+2V x x x 1 1 - #0000..#FFFF
10. Signals /001 and /10X are used to activate EEPROM and SRAM. This is done with second half of 74*139 decoder and OR gate made from resistor and NPN transistor. Resistor is inserted in /MREQ line giving /MEM signal. /MEM signal can be pulled up by the Q0 line (and transisor) when the ZX1541 has to be disabled by setting bit 0 in #BF port. When not disabled, /MEM signal works like /MREQ:
Q0 /MREQ /001 /10X /MEM /EEPROM /SRAM - adresses
0 0 0 1 0 0 1 - #8000..#BFFF
0 0 1 0 0 1 0 - #2000..#3FFF
0 0 1 1 1 1 1 - other than above
0 1 x x 1 1 1 - #0000..#FFFF
1 0 x x 1 1 1 - #0000..#FFFF
1 1 x x 1 1 1 - #0000..#FFFF
11. Bits 2, 3, 4, 5 of value outed to #BF ports can force low state on IEC lines /RESET, /ATN, /CLK, /DATA when are set to 1. When these bits are written as 0, IEC lines are in high state unless other IEC interface forces low state
with open collector output gates. Lines are pulled up to +5V by 1kohm resistors, while 1N4148 diodes force the IEC voltage to be in range -0.7V to 5.7V.
12. IEC lines can be read in bits 4, 5, 6, 7 in #BF port, /RESET, /ATN, /CLK, /DATA respectively. In original design only /CLK and /DATA lines were available, so the ZX81 wasn't able to act as IEC slave device (as a controller, terminal device, perhaps 1541 simulator).
13. Two LEDs are added. One lights when DISIN is high, what means interface is disabled. It should blink very fast in normal using, get dark while IEC operations and ligh continously when "next" interface disables ZX1541. Second LED is connected to IEC data line and shows the IEC is sending data. Third diode could be connected to Q0 signal showing the interface is software disabled.
Mounting ZX1541 on Split interface.
(To be continued.)
Link to comment
Share on other sites

You've been talking about the electrical side of the problem. However, I think the software interface will be at least as hard to adapt. Commodore has a very *special* disk layout. The tracks are bundled in zones with specific numbers of sectors; some details can be found on http://unusedino.de/ec64/technical/formats/d64.html.

 

For that reason, C64 disks are pretty difficult to dump, unlike TI disks, which are quite easy to be read in a PC floppy drive (because of the standard layout).

 

The problem may be that the TI file system assumes a constant number of sectors per track, so you won't be able to use any existing low-level routines. Eventually, you will end up with a completely new DSR. Still, you won't be able to read any disk written by a TI floppy system.

 

I'd say it's not impossible, but it may turn out to be a bigger project.

Link to comment
Share on other sites

Sorry, tl;dr (for now)

 

I have theorized and postulated on the idea of connecting a CBM serial drive to the TI. Even with the differences in file systems, encodings, sector layouts, etc., the DOS on the drives themselves is standard and offers mid- and high-level access to the disks. IMUO, it would take a competent DSR and a proper CBM serial interface to make it work native to the TI, or a utility program which can speak CBM's 488-serial protocol to do things like open and close files, read and write to files, and so on. At a middle level there are commands which can directly access contents of sectors (or "blocks" in CBM parlance) on the drive, which would require knowledge of the track layout schemes but I do not see it as any different than doing direct access on a real commodore. The GCR encoding need not be handled by the TI as a drive's on-board DOS can do that or be told to do that for the TI -- which is good since the 1581 uses MFM but the same DOS and block commands.

 

The bigger question is what purpose this would serve. In theory one could use a 15x1 drive to store TI data, or use a TI to read Commodore data and programs. A program would have to convert CBMSCII to ASCII (not such a big deal) to make read data useful. Of course, this could be used to pull SIDs off long-lost CBM floppies to use with Marc's PEB SID card :)

Link to comment
Share on other sites

As for number of sectors per track, that normally is something the drive handles on its own. Only if you specifically ask to read or write individual sectors, you have to bother with that. Regular load/save functions, as far as I can tell, will allocate available sectors as they go.

 

1541 type drives have been interfaced with many non-Commodore applications, besides the ZX-81 mentioned above I've heard about synthesizers wired to use a 1541 and other computers and devices too. When it comes to dumping floppy disks, you can use a ZoomFloppy interface or any of the X*1541-series cables. You could also use something like a Catweasel, Kryoflux, SuperCard Pro etc to connect a regular floppy drive to. So yes, it takes a bit more hardware than dumping MFM formatted floppy disks, but far from impossible.

 

If you get a 1571, I believe it can be modified to take MFM formatted disks too, which means you might end up wiht a standalone, intelligent drive that both takes C64 and TI formatted disks, but it would not be automatical.

Link to comment
Share on other sites

The 1571 supports MFM natively with the proper settings (a ton of U0 commands for this,) which programs like BigBlueReader and the CP/M+ OS exploited readily. I believe it can do FM, as well. That could make for an easy way to get odd formats which the TI cannot get using its interface, though the 1571 and the TI controller use the same family of chips (WD 177x.)

Link to comment
Share on other sites

Yes, you can certainly write a DSR which tries to hide all the specifics of the 1541/71. I'm not sure whether we have some specialties in the TI file system that imply a particular handling, though. If you can tell the 1541/71 to access single sectors you should be able to implement the whole file management on top. But I don't know enough about it.

Link to comment
Share on other sites

I just thought as Commodore and Atari 5.25 floppy drives are cheap, serial and available, it might make a good way of adding A floppy drive or two where a fully loaded PEB is no longer possible. Compatibility with TI-99 disks would be 'NICE' too, but not the end of the world.

 

I have a heap of Commodore 1541, 1541-II and clones.,,,, collecting dust.

 

Then there is the Atari drive 810 & 1050, Disk Drive, also cheap although not so commonly found?

Link to comment
Share on other sites

I am not familiar enough with how the Atari drives work to speak to those, but I am familiar with the 1541/71/81. A PEB card with a 6-pin DIN hanging off the back would be pretty cool. A DSR which would access say CBM8, CBM9, CBM10, etc. (based upon device number.)

 

For that matter, a CBM4 for a printer. Such a DSR could use the native drive DOS or even access lower-level MFM functionality of the 1571 and 1581 to create TI-alike disks. I am curious if the drives would even read a TI disk. I suspect they will, again given that they use the same chips.

 

hrmmmm... for that matter, maybe even a quick-n-dirty DOS to run on the drive to provide TI disk functionality. Imagine that, a TI DOS implemented in 6502 running on a Commodore floppy drive. I would have to check, but I believe the 1571 would be required over the 1541 as I am almost positive it has more RAM. Of course, the MFM functionality alone makes it a requirement over the 1541.

 

If the 6581 can be implemented on the 9900 buss, then a 6522 or 6526 should be viable, as well. Of course, where to get a good supply of those. Probably be best to run some kind of FPGA (forgive me if I misuse the term) or other integrated controller which could talk to the TI and the CBM serial. OH!! It could implement burst-mode transfers, too, with the 1571 and 1581. Maybe JiffyDOS (since its disassembly is available) but I do not see the benefit in this scenario versus burst transfer with MFM.

 

(walks off muttering excitedly to self)

Link to comment
Share on other sites

Ditto, I built both my "Amiga1541" and XM1541 myself. Very basic designs once you get into studying them. The reason they use parallel ports on the Amiga/PC is because the 1541 uses separate signals for clock, attention and data so a plain serial port usually isn't enough.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...