Software for an S-100 Bus Computer using MSX video hardware.

Page 1/7
| 2 | 3 | 4 | 5 | 6

By monahanz

Rookie (21)

monahanz's picture

23-01-2014, 07:09

This is my first post here. Hope one of you experienced programmers can help.
I am a member of a group of people that make and use S-100 bus based computers. See for example
www.S100Computers.com and www.n8vem-sbc.pbworks.com/w/page/4200908/FrontPage.

We design new boards and have done so now for video boards, RAM/ROM board and a number of CPUs (Z80, 6502, 8088, 8086, 80286, 80386, 68K etc). Amongst the ongoing projects is one to build a MSX compatible hardware platform. I have been working on the video/sound part of the project and while progress is slow we are getting there.

If you look at http://www.s100computers.com/My%20System%20Pages/VDP%20Video...
you will see I can get 40X25 chars/lines on the screen. However when I try to get 80X25 chars resolution I always end up with duplication of the top lines of text half way down the screen. It looks like I am not initializing some V9938 register correctly. The problem I have is I cannot find an example of code where the V9938 is initialized from reset to yield this resolution. I tried setting/resetting various bits in R#0 to R#9 etc with no luck.

Could somebody here provide Z80 source where from a “cold start” the V9938 in correctly initialized to display text in 80X25 format.

Login or register to post comments

By NYYRIKKI

Enlighted (5899)

NYYRIKKI's picture

23-01-2014, 09:41

Try ie.:
R#0=R#0 AND 241 OR 4
R#1=R#1 AND 167 OR 80
R#2=3
R#4=2

(Map=0, Fonts=4096)

By Manuel

Ascended (18398)

Manuel's picture

23-01-2014, 13:31

Offtopic, but @monahanz: there's quite some nonsense in the intro about MSX... check the "What is MSX?" FAQ...

If you're using a V9938, you can just as well go for MSX2 compatibility. The VDP is the main difference.

I guess for all MSX stuff you can get a lot of info from people here on the forum. Don't hesitate to ask!

By monahanz

Rookie (21)

monahanz's picture

23-01-2014, 17:11

Thanks NYYRIKKI, what do yo mean by R#0=R#0
Do I just set R#0 to 241 try it, if that does not work try R#0 set to 4. In both case setting R#1 to 167, R#2 to 3 and R#4 to 2.

If that fails try setting R#0 to 241 try it, if that does not work try R#0 set to 4. In both case setting R#1 to 80, R#2 to 3 and R#4 to 2. Looks like 8 combinations! Can this be narrowed down.

By NYYRIKKI

Enlighted (5899)

NYYRIKKI's picture

23-01-2014, 18:43

No, I meant bit-wise OR and AND... Meaning practically that I don't know how you want to setup the interrupts etc... In typical MSX environment R#0=4 and R#1=112

By yzi

Champion (444)

yzi's picture

23-01-2014, 18:46

I think Nyyrikki means binary operations. 241 = 128 + 64 + 32 + 16 + 1, meaning 11110001 in binary. The first operation in essence clears the second and fourth bits, sets the third bit i.e. bit 2 ("OR 4"), and leaves all other bits to whatever they were. Edit: I was too late.

By monahanz

Rookie (21)

monahanz's picture

23-01-2014, 19:43

Sorry for being so "slow" on this guys. Never worked with the V9938 before. There are no hardware ints used in this system. As I am said, I'm starting from a cold/reset start in however the V9938 initilizes itself on warm-up. All I want it to do is put 80 characters on 24/25 lines. If I have it correct, “Text Mode2”.
Here is what i have so far. I and using the IBM-PC BIOS ROM character set (here located at CHARS_IBM)
VDP data port = 98H
VDP command (CMDP) port = 99H

LD C,CMDP ; Port always in [C], Register pointer in [E]

LD A,80H ;Point to R#0
LD E,11110001B ;Value to place in R#0
OUT (C),A
OUT (C),E

INC E ;Point to Register #1 to F7H
; Select 80 column mode, enable screen and disable vertical interrupt
LD A,0F7H
OUT (C),A
OUT (C),E
;----------------------------------------
INC E ; Register #2 to 3H
; Set pattern name table (not clear why 3)
LD A,3
OUT (C),A
OUT (C),E
;----------------------------------------
INC E ; Register #3 skip
INC E ; Register #4 to 2H
; Set pattern generator (not clear why 2)
LD A,2
OUT (C),A
OUT (C),E
;----------------------------------------
LD E,87H ; To Register #7
; Set colors to white on black
LD A,0F1H ; Bits 7-4 = Text color (White), Bits 3-0 Background color (Black)
OUT (C),A ; Data = 0F1H (white on black)
OUT (C),E

;----------------------------------------
INC E ; To Register #8
LD A,09H ; *** (00001001) = no mouse,no LP, set color code,color bus output mode,
; VRAM = 64K , 0, Sprite disable, Set to B&W
OUT (C),A ; *** Send 00001001
OUT (C),E

;--------------------------------------
LD E,89H ; Register #9
; Cycle Mode S1=1 S0=0
; IL=0 E0=0
LD A,24H
OUT (C),A
OUT (C),E

;--------------------------------------
INC E ; Register #A to 0H
; Color Table base address Higher Order BitsBits A16 to A14
; (Lower Order Bits A13 to A9 loaded into #R3
LD A,00H
OUT (C),A
OUT (C),E

XOR A ; Let's set VDP write address to #0000
OUT (CMDP),A
LD A,40H
OUT (CMDP),A
; Clear first 16Kb of VDP memory
LD B,0
LD HL,3FFFH
LD C,DATAP

CLEAR: ;Clear screen
OUT (C),B
DEC HL
LD A,H
OR L
NOP ; Let's wait 8 clock cycles just in case VDP is not quick enough.
NOP
JR NZ,CLEAR

; ----------------------------------------
LD C,CMDP ; Let's set VDP write address to 808H so, that we can write
LD A,8 ; character set to memory
OUT (C),A ; (No need to write SPACE it is clear char already)
LD A,48H
OUT (C),A

; Let's use the IBM-PC ROM BIOS character set
PUSH BC ; Save C
LD HL,CHARS_IBM
LD B,(CHARS_END_IBM-CHARS_IBM)/8 ;Number of 8 byte characters to move

COPYCHARS:
LD C,8 ; 8 bytes per character

COPY1: LD A,(HL)
OUT (DATAP),A
INC HL
NOP ; Let's wait 8 clock cycles just in case VDP is not quick enough.
NOP
NOP
NOP
DEC C
JP NZ,COPY1
DJNZ COPYCHARS

POP BC ; Return C

XOR A ; Let's set write address to start of name table
OUT (C),A
LD A,40H
OUT (C),A

;====== We are done setting up registers! =======
;Let's set write address to start of "name table" (CRT Display)
LD IY,0 ;[IY] Will ALWAYS hold the line number on screen (0 - 23)
LD IX,0 ;[IX] Will ALWAY hold X position on current line (0 - 39)
XOR A
OUT (C),A ;send 0 to CMD port
LD A,40H
OUT (C),A

PUSH HL
PUSH DE
PUSH BC
LD HL,VH_SIGNON ;Send VPD Board signon message to VGA display
CALL VPSTRING :Routine to send ascii string to screen
POP BC
POP DE
POP HL
;------- MAIN LOOP ------------------

NEXTCHAR:
CALL ZCI ;Stay here until keyboard hit on System console input port
CP A,ESC ;if ESC then abort
JP Z,DONE
LD C,A
CALL ZCO ;Char will still be in [A] on return
CP A,CR ;If CR then special treatment
JP NZ,NO_CR ; not CR/LF display character

CALL DO_CR ;Special treatment for CR+LF
JP NEXTCHAR

NO_CR: ;Not a CR/LF so display character with V9938 directly
SUB A,1FH ;Adjust ASCII to table offset
OUT (DATAP),A ;Send character to DATA PORT
CALL UPDATE_POSITION ;Update cursor positioning data
JP NEXTCHAR

VPSTRING: ;Print a string in [HL] up to '$' on V9938 VGA Display
LD A,(HL)
CP A,'$'
RET Z
SUB A,1FH ;Adjust ASCII to table offset
OUT (DATAP),A
CALL UPDATE_POSITION ;Update cursor positioning data
INC HL
DJNZ VPSTRING

DONE:
LD C,00H ; CP/M SYSTEM RESET CALL
CALL 0005H ; RETURN TO CP/M PROMPT

By flyguille

Prophet (3028)

flyguille's picture

23-01-2014, 23:31

wait, in that website you has images of using the msxbasic, why you not use SCREEN0:WIDTH 80 ?

By flyguille

Prophet (3028)

flyguille's picture

23-01-2014, 23:43

anyway the website has nosense information about the VDP

Quote:

The S-100 VDP will contain all the circuitry necessary to generate tan MSX style video display. It appears to the S-100 bus Z80 as two I/O ports called the Data Port and the Command Port. Although the VDP has its own 16 KB of VRAM (Video RAM), the contents of which define the screen image, this cannot be directly accessed by the Z80. Instead it must use the two I/O ports to modify the VRAM and to set the various VDP operating conditions. The VDP video chip we use is the Yamaha V9938 chip.

v9938 must come with 128KB VRAM, not 16K, 16K is an option, but not used in the standard MSX2, only if the chip is 9918 (MSX1 only) it has 16K, but the vdp9938 is for msx2, and 80 text columns is MSX2 standard, not msx1.

the v9938 uses two banks, they works interleaved or so, not one bank like the 9918.

another thing MSXBIOS/BASIC requires the 50 or 60hrz INT/ signal coming from the VDP directly to Z80. If it is doing a periodic INT/ from other source, don't expect MSX software to work, overall the MSX2 games, all the drawing is done during video VBLANK because during that period the VDP can get more data traffic than during the image render period.

By NYYRIKKI

Enlighted (5899)

NYYRIKKI's picture

24-01-2014, 00:10

Sorry, but all wrong... In register 0 & 1 set you have mixed register A & E meaning and you are using wrong values...

Here is a fixed start:

LD	C,CMDP	 ; Port always in [C], Register pointer in [E]

LD E,80H ;Point to R#0
LD	A,00000100B	;Value to place in R#0
OUT (C),A
OUT (C),E

INC E ;Point to Register #1
; Select 80 column mode, enable screen and disable vertical interrupt
LD	A,01010000B
OUT	(C),A
OUT	(C),E
.
.
.

to be honest, I didn't bother to read much further...

By sd_snatcher

Prophet (3498)

sd_snatcher's picture

24-01-2014, 02:00

@monahanz

First, be welcome to the MSX community! Your idea is great and it will be definitely awesome if it allows the S-100 community join us and enjoy MSX software. A larger user base have a lot of advantages, and even MSX software/hardware producers will be able to reach a broader audience.

And it’s also exciting to think that someone will be able to run MSX games on their Altair 8080 machine. Big smile

But I (and probably others here who could help you) don’t have any deep knowledge on S-100 systems. If you could detail your machine’s configuration, then we could try to think a way to bridge both worlds the best possible way. The MSX standard was designed to be flexible enough to accommodate a lot of underlying hardware differences.

For example:

1) But AFAIK, the Z80 used on those systems is 4MHz/zero wait states, right?
2) What ports are already used on your machine?
3) How is its memory organization? IOW, how is its memory address space organized? Is the RAM on the same board as the Z80 or is it on a separate board?
4) Does your S-100 computer allow memory mapped devices? How’s the RAM vs devices address overlap solved?
5) How does it boot? Do you run CP/M?
6) How does the keyboard on the host system work? Is it a PS/2 keyboard?

Some other tips:

1) The MSX-BIOS is the software heart of the MSX machine. Unless you intend to do a lot of hacking on MSX programs to run them, you will need the BIOS. And since you don’t seem to be very intimate of the MSX chips, you will need the BIOS even more, since it does all the dirty work for you.

But keep in mind that only well behaved software (that respect the coding guidelines) will be able to run on your S-100 machine anyway. But of course it’s much easier to patch them to behave correctly than to patch them to run without any BIOS on a completely different machine.

2) You can get rid of the RAMDAC you connected to the VDP. No offense meant, it’s just that it's not needed and will just create an incompatible way to generate the palette. The Yamaha VDPs feature their own DAC circuitry and palette generator built-in. Connect the VDP's R,G,B output pins to a Sony CXA1645 and you’re good to go in RGB, S-Video and Composite Video style. Smile

3) Unless you want to be restricted to the MSX1, connect 128KB of VRAM to the VDP. With only 16KB you will be missing a lot of really fun software.

4) Your MSX S-100 card doesn’t have an MSX slot. It will be required if you plan to run cartridges. It’s also advisable to include at least one MSX joystick port.

Page 1/7
| 2 | 3 | 4 | 5 | 6