• ImHuman

  • by magicaros

Commodore computers where humanly understandable in their whole, who today still know his computer as intimately as we know our commies? That's why i love C= ! beside Retro is the new hype :p

Feb
26

C64 CP/M Cartridge - The under estimated

Back in the 80's when the CP/M cartridge was realised, it was rushed to the market and had flaws that made it unsuccesfull, however There is some very under estimated aspect of the cartridge that many failled to see back then. let's explore them!

Back in the 80's when the CP/M cartridge was realised, it was rushed to the market and had flaws that made it unsuccesfull, First let's see what's bad then we will explore the underestimated aspect of that little piece of hardware.

to resume most of the bad stuff... It's all the fault of the C64.

the disk format of the 1541 drive (actually C64 cpm was designed for 1540 or 4040 drives and made it possible to use 2 drives with the 4040 dual drive unless you patched it) was a culprit because it's total incompatibility with any other cpm disk format wich make it very difficult to get software for it as the only option back then was to use the userport RS232 to transfer to memory and save to disk

C64 had only 40COL display, and unlike cpm+ 3.0 on the C128 you couldn't scroll to a virtual 80COL kind of terminal in 40COL mode, most of the productive software running on cpm would not act nicely on a 40COL screen make them useless, attempt have been made to circumvent that flaw, enter SOFT80.COM a software 80COL mode for c64 cpm except... the terminal is too dumb and it was almost impossible to reconfigure most of the existing productive software to play nicely with it. there is also TVBIOS.COM wich circumvent the dumbness of the terminal to make act like an TVI 920 in 40COL mode but then again it is only 40COL to make it worse TVBIOS & SOFT80 don't play nice along... bummer!

Strangely enough, by opposition and although it is kind of paradoxal, the good stuff and underestimated aspect of the CP/M cartridge is all because it's a C64 Let see why...

With the CP/M cartridge plugged into your C64 and cpm running what did you get? the answer is easy and very straight forward, a C64 with a convenient disk operating system and a Z80 cpu. in fact it is the same old C64 you always knew and loved just with his memory map rotated by a 4K offset and that's exactly where the cartrigde was underestimated. 

The whole 64 memory map is visible by the Z80 including the mapped I/O at $C000 instead of $D000 on the 6510, the zero page of the 6510 is located at $F000 the screen is at $F400 etc... wich mean, it's totaly possible to code in 8080 or z80 assembly and bitbang the VIC or the SID without the need of the 6510. But of course if you want to you can also call 6510 from the Z80 to do some stuff and get back to the z80

For instance, let say i want to display a picture on the screen using our good old VIC-II multicolor mode under cpm, well yes i can and i can do it using only 8080 or Z80 code... here's an example in 8080 were the only call to the 6510 are performed only through cpm bdos call (we want console input so we can press enter and return to cpm after displaying the picture)

ORG 0100h    ; cpm tpa start

 
BDOS EQU 00005h
 
LDA 0C011h    ; save vic register for later
STA 03000h
LDA 0C016h
STA 03001h
LDA 0C018h
STA 03002h
LDA 0C020h
STA 03003h
LDA 0C021h
STA 03004h
 
LXI H,04400h ; register pair as source (HL)
LXI B,0F400h ; register pair as destination (BC)
LXI D,0h ; register pair as count (DE)
loop1: MOV A,M         ; mem copy form 04400h to C64 SCREEN RAM
STAX B
INX H
INX B
INX D
MVI A,4
CMP D
JNZ loop1
 
LXI H,03800h ; register pair as source (HL)
LXI B,0C800h ; register pair as destination (BC)
LXI D,0h ; register pair as count (DE)
loop2: MOV A,M         ; mem copy from 03800h to VIC COLOUR 
STAX B
INX H
INX B
INX D
MVI A,4
CMP D
JNZ loop2
 
MVI A,6   ;set border and background
STA 0C020h
MVI A,0
STA 0C021h
MVI A,59   ; set vic register for display multicolor bitmap
STA 0C011h 
MVI A,24
STA 0C016h
STA 0C018h 
 
loop: MVI C,1    ; console input function
CALL BDOS  ; we call cpm dbos
MVI B,32   ; N.B. console input cause cursor to appear on top of pic but that the easiest way
CMP B
JZ loop
 
quit: LDA 03000h    ; restore vic register
STA 0C011h
LDA 03001h
STA 0C016h
LDA 03002h
STA 0C018h
LDA 03003h
STA 0C020h
LDA 03004h
STA 0C021h
 
MVI C,9    ; console output function
LXI D,MSG  ; parameter
CALL BDOS  ; we call cpm dbos
 
MVI C,0    ; reset function, we want to reload cpp/bdos and ensure everything in place
CALL BDOS  ; call it
 
RET   ; that return is never reached but we leave it here in case something wrong
 
MSG: 
DB 0Ch,'$' ; ASCII Form FEED (clear the screen)
 
BITMAP DATA FOLLOW at $1000 ($2000 for the 6510) SCREEN DATA at $3800 & COLOR DATA at $4400
 
And here's a video of the code running...

and here we go... so did you learn anything? yes? well please code a demo then !

Leave a Comment

You must be signed-in to post comments.

Responses