Jump to content

Photo

CP/M related questions


8 replies to this topic

#1 Vorticon ONLINE  

Vorticon

    River Patroller

  • 3,791 posts
  • Location:Eagan, MN, USA

Posted Sat May 11, 2019 7:03 AM

Since I foresee having lots of questions related to CP/M on the Adam, I figured I might as well create a bucket topic for them. Who knows, it might even be useful for others! :)

So my first question is: how does one access the VDP (video display processor) from CP/M in assembly? On the TI 99/4A, which uses a similar VDP chip (9918A), the assembler has instructions specifically designed for this purpose to set up the VDP registers and read/write data from/to the VDP RAM space which is separate from the user RAM.

At this time I'm looking to switch from graphics mode to 40 col text mode under CP/M, although of course having complete access to the VDP would be awesome!



#2 Vorticon ONLINE  

Vorticon

    River Patroller

  • Topic Starter
  • 3,791 posts
  • Location:Eagan, MN, USA

Posted Mon May 13, 2019 7:11 AM

So I made a little progress in figuring this out via the Hacker's guide and the Adam technical reference and it looks like ports 190 and 191 on the Z80 are mapped to the VDP and I should be able to access it using an OUT instruction in assembly. I need to experiment a bit though because the Hacker's guide does not give any examples on how to do it in practice.

Unfortunately, the OUT instruction is throwing a syntax error every time during assembly with the ASM assembler under CP/M even though I know my syntax is correct. 

OUT (C),B

This should work, transferring the 8-bit contents of register B to the port referenced by register C.

Does anyone here have any experience with the OUT instruction on the Adam?



#3 Milli Vee OFFLINE  

Milli Vee

    Chopper Commander

  • 161 posts

Posted Mon May 13, 2019 9:48 AM

So I made a little progress in figuring this out via the Hacker's guide and the Adam technical reference and it looks like ports 190 and 191 on the Z80 are mapped to the VDP and I should be able to access it using an OUT instruction in assembly. I need to experiment a bit though because the Hacker's guide does not give any examples on how to do it in practice.

Unfortunately, the OUT instruction is throwing a syntax error every time during assembly with the ASM assembler under CP/M even though I know my syntax is correct. 

OUT (C),B

This should work, transferring the 8-bit contents of register B to the port referenced by register C.

Does anyone here have any experience with the OUT instruction on the Adam?

HI - I have TONS of experience with programming the Adam and the z80 - it is better to contact me on FB or via email - I do not come on here often

 

William "Milli" Hicks



#4 Vorticon ONLINE  

Vorticon

    River Patroller

  • Topic Starter
  • 3,791 posts
  • Location:Eagan, MN, USA

Posted Tue May 14, 2019 5:07 AM

HI - I have TONS of experience with programming the Adam and the z80 - it is better to contact me on FB or via email - I do not come on here often

 

William "Milli" Hicks

 

Done :)



#5 Vorticon ONLINE  

Vorticon

    River Patroller

  • Topic Starter
  • 3,791 posts
  • Location:Eagan, MN, USA

Posted Tue May 14, 2019 5:30 AM

For the benefits of others however, it turned out that the OUT instruction which is Z80 specific is not supported by the standard CP/M 2.2 assembler ASM as the latter only recognizes 8080 code, a subset of Z80. Did not know that... On real hardware, the workaround is to replace the OUT instruction with its proper opcode in the hex file, a pain at the very least. Under emulation, Mili Vee suggested using an online Z80 assembler here: http://clrhome.org/asm/.

I did a small test in DDT on my Adam machine to set up 40 col text mode using the following code (no comments in DDT and replace out©,b with ED41). Run with a g100 assuming you started assembly at 100h (bottom of TPA). This code tidbit should complement the info in the Hacker's guide.

mvi c,bf ;VDP port address in c
mvi b,21 ;green on black
out (c),b ;write byte to port
mvi b,87 ;select VDP register 7
out (c),b
mvi b,f0 ;set up VDP register 1 for text mode
out (c),b
mvi b,81 ;select VDP register 1
out (c),b 
rst 7 ;return to CP/M


#6 Milli Vee OFFLINE  

Milli Vee

    Chopper Commander

  • 161 posts

Posted Tue May 14, 2019 8:29 AM

I'll post this here but the discussion will be on FB
 

I have just finished reverse engineering how CP/M sets up the VDP. For those of you that want access graphics in CP/M here is the basic CPM VDP setup

 

Notes: CPM breaks the screen up into thirds: TOP, MID, BOT
CPM uses a sprite for the cursor

0000h - 07FFh Font patterns for the top 8 lines of screen

0800h - 0FFFh Font patterns for the middle 8 lines of screen

1000h - 17FFh Font patterns for the bottom 8 lines of screen

1800h - 18FFh Characters for the top 8 lines

1900h - 19FFh Characters for the middle 8 lines

1A00h - 1AFFh Characters for the bottom 8 lines

1B00h - 1FFFh Unused, CP/M may use for scratch RAM

2000h - 27FFh Colors for the top 8 lines of the screen

2800h - 3FFFh Colors for the middle 8 lines of the screen

3000h - 37FFh Colors for the bottom 8 lines of the screen

3800h - 387Fh Sprite Data, 128 bytes used for cursor

3880h - 38FFh Sprite attributes

3900h - 3FFFh Unused, CP/M may use for scratch RAM
 

Milli



#7 Vorticon ONLINE  

Vorticon

    River Patroller

  • Topic Starter
  • 3,791 posts
  • Location:Eagan, MN, USA

Posted Tue May 14, 2019 8:45 AM

Excellent! This is extremely helpful! 



#8 Vorticon ONLINE  

Vorticon

    River Patroller

  • Topic Starter
  • 3,791 posts
  • Location:Eagan, MN, USA

Posted Sat May 18, 2019 1:12 PM

As I was inspecting the VDP map Milli put up, I realized it was nothing more than the standard bitmap mode!

I confirmed that by playing with the VDP registers a little. Why they did not instead go for the much easier to use text mode is unclear to me... At the very least they could have changed the character set to accommodate 40 columns in bitmap rather than the ridiculously complicated 32 col scheme. 

Jeff Brown even created an 80 col font for the bitmap mode which was used in his Term80 terminal program for the TI 99/4A to emulate 80 columns on the VDP. It was surprisingly readable! Theoretically one should be able to patch the CP/M BIOS on the Adam to load the 80col font on startup from disk and change the display scheme to suppress scrolling and we should end up with an 80 column system with no additional hardware. BIOS hacking is not trivial though... Something for me to look into at some point :)



#9 LoTonah OFFLINE  

LoTonah

    Dragonstomper

  • 559 posts
  • Location:Penticton, BC Canada

Posted Yesterday, 5:56 AM

Yes, please do! Thanks to you guys we hopefully soon will be able to program graphics, sound and joystick controls in CP/M (and even better, Turbo Pascal), in 80 columns. I think that will usher in a new wave of CV games, and Adam software too.




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users