What is needed to bring-up Coleco ADAM as a CPM suibtype?

Post Reply
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

What is needed to bring-up Coleco ADAM as a CPM suibtype?

Post by tschak909 »

The Coleco ADAM could potentially be provided as a +cpm subtype, as it is literally the same hardware as countless other machines that Z88dk supports, just with a different memory map...

What needs to happen?

-Thom
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I've done a few of these CP/M machines lately, the process tends to be:

1. Gather ROMs and boot disks for target machine
2. Update appmake to generate a CP/M disc with the right geometry (assuming the disc format isn't a weird one)

Once that is done, it'll be a case of copying what was done for the Einstein - allowing access to the TMS and sound libraries from CP/M.

It's not usually a massive amount of work - if you can give some pointers to roms and disks I'll take a look over the weekend.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I've managed to track everything needed down.

It's a slightly odd disc format - the directory is at an unusual offset, correcting for that I can't load the file correctly so something else is going on.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

As usual, I forgot about disk skew.

I've added all the Colecovision routines the adam library. A cursory test shows that the VDP stuff is working. The chosen option is -subtype=adam

Enjoy
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

You guys are beyond awesome. *hug*

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

Don't get mad, but...

The good news, PLATOTerm built.

The bad news? After blanking the screen for a bit, it eventually returned to CP/M... is the graphics.h not able to run on ADAM, yet? (will I need to port to use the coleco lib?)

-Thom
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I?ll take a look - It should work since gencon works but some ports need a couple of minor tweaks.
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Oh, this is special. Okay, so when we change modes it looks like we enable the VDP interrupt.

On the Adam this ends up as an NMI.

However, there's no code to handle the NMI so it ends up jumping into the middle of the CP/M interpreter.

So, we need to stick a retn at 0x66 so that we don't jump into space. I can't think of a sensible way to do this at the moment in the libraries, so for the moment can you stick:

Code: Select all

        ld      hl,0x45ed
        ld      (0x66),hl
Somewhere near the start of your code
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

e.g. like a function that does some inline asm?

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

That worked a treat! :)

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

Both the Z88DK and CC65 communities are doing _AMAZING_ work. Thank you all, for hacking on these excellent C compilers... It's _the_ reason my project is able to exist.

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

PLATOTerm running under CP/M on ADAM.

Image

I just need to work with the community to fill in the needed RS232 routines.

-Thom
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

also, dunno if this is a bug or not, but I had to alter my makefile slightly, it places the binaries in a build/ directory, so when appmake was making the disk image, it puts "BUILD/PL.COM" in the directory... for now, I've worked around it in the makefile, but, am wondering if I am doing something fundamentally wrong?

-Thom
User avatar
dom
Well known member
Posts: 2076
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Yeah that was a dumb bug. You can tell I don't build stuff that way!

Consider it now fixed.

Does the tty device not map onto serial?
tschak909
Well known member
Posts: 171
Joined: Sun Sep 09, 2018 5:44 pm

Post by tschak909 »

not sure. I have some code here for a serial device on the ADAM though:

Code: Select all

DataPort .equ 044h ; Data port (in/out)
StatPort .equ 045h ; Status port (in)
BaudRatePort .equ 046h ; Baud rate port (out)
ControlPort .equ 047h ; Control port (out)
InMask .equ 2 ; 8251 RxRDY
OutMask .equ 1 ; 8251 TxRDY
ChipSet .equ 037h ; 8251 RTS,ER,RxE,DTR,TxEN
ChipOff .equ 035h ; 8251 RTS,ER,RxE,TxEN (no dtr)
Break .equ ChipSet | 8 ; ChipSet OR send break
Freeze .equ 022h
Reset .equ 027h

n71 .equ 001001010b ; 7n1
n81 .equ 001001110b ; 8n1
n72 .equ 011001010b ; 7n2
n82 .equ 011001110b ; 8n2
e71 .equ 001111010b ; 7e1
e81 .equ 001111110b ; 8e1
e72 .equ 011111010b ; 7e2
e82 .equ 011111110b ; 8e2
o71 .equ 001011010b ; 7o1
o81 .equ 001011110b ; 8o1
o72 .equ 011011010b ; 7o2
o82 .equ 011011110b ; 8o2

b19200 .equ 03fh ; 19200
b9600 .equ 03eh ; 9600
b4800 .equ 03ch ; 4800
b2400 .equ 03ah ; 2400
b1200 .equ 037h ; 1200
b600 .equ 036h ; 600
b300 .equ 035h ; 300

BitParityStop .equ n81
BaudRate .equ b300

Echo .equ FALSE

SerialTest: .module SerialTest

ld a,BaudRate ; Setup the serial port
call SetBaudRate
ld a,BitParityStop
call SetBitSetup
call DTROn
call BreakOff

_keyLoop:
call STARTREADKEY ; Setup the keyboard read
jr nz,_keyboardError ; Keyboard error so exit

_loop:
call CharInput ; Get any character from the Serial port
jr nc,_noSC ; Jump if none
call PrintByte ; Display what we got
_noSC:
call ENDREADKEY ; End the keyboard reading
jr nc,_loop ; No key so continue
jr nz,_keyboardError ; Keyboard error so exit
call CharOutput ; Send the character in A
#if Echo = TRUE
call PrintByte ; Echo to our screen
#endif
jr _keyLoop ; Reset the keyboard read

_keyboardError:
ld hl,Serial_KB_Error
call PrintString
Stop

Serial_KB_Error:
.text "Keyboard Error"
.db NULL

; Gets a character from the Serial input if there is one and returns it in A
; If NC set then no character

CharInput: .module CharInput
in a,(StatPort) ; Get the input status
and InMask
rra ; Rotate into carry
rra
jr nc,_exit ; No character so exit
in a,(DataPort) ; Get data
_exit:
ret
; Send the character in A out the serial port, waiting till it is ready to go

CharOutput: .module CharOutput
push af ; Save character
_loop:
in a,(StatPort) ; Get the output status
and OutMask
rra ; Rotate into carry
jr nc,_loop ; Not ready, check again
pop af ; Get character back
out (DataPort),a ; Put data
ret

; Get serial data into A

SerialInput:
in a,(DataPort) ; Get data
ret

; A = 2 if data has been received (RxRDY)

SerialInputStatus:
in a,(StatPort) ; Get the input status
and InMask
ret

; Put serial data from A

SerialOutput:
out (DataPort),a ; Put data
ret

; A = 1 if ready to send data (TxRDY)

SerialOutputStatus:
in a,(StatPort) ; Get the output status
and OutMask
ret

; Turn DTR On

DTROn:
push af
ld a,ChipSet
out (ControlPort),a
pop af
ret

; Turn DTR Off

DTROff:
push af
ld a,ChipOff
out (ControlPort),a
pop af
ret

; Start serial port break

BreakOn:
push af
ld a,Break
out (ControlPort),a
pop af
ret

; Stop serial port break

BreakOff:
push af
ld a,ChipSet
out (ControlPort),a
pop af
ret

; Set the baud rate to the value in A

SetBaudRate:
push af
push bc
ld b,a
in a,(BaudRatePort)
ld c,a
in a,(BaudRatePort)
ld a,Freeze
out (ControlPort),a
ld a,c
out (BaudRatePort),a
ld a,b
out (BaudRatePort),a
ld a,Reset
out (ControlPort),a
pop bc
pop af
ret

; Set the bit setup to the value in A

SetBitSetup:
push af
push bc
ld b,a
in a,(BaudRatePort)
in a,(BaudRatePort)
ld c,a
ld a,Freeze
out (ControlPort),a
ld a,b
out (BaudRatePort),a
ld a,c
out (BaudRatePort),a
ld a,Reset
out (ControlPort),a
pop bc
pop af
ret
Post Reply