Writing / Reading VRAM - noob questions

Página 2/9
1 | | 3 | 4 | 5 | 6 | 7

Por siudym

Resident (39)

Imagen del siudym

12-12-2021, 14:31


UpdateBuff:

        DI
	LD HL,1B00h						; point to start of SA in vram.

	LD A,L
	OUT (99h),A
	LD A,H
	OR $40
	EI
	OUT (99h),A

	LD B,128 (127?)						; amount of bytes to output.
	LD C,98h						; destination is vdp data port.
	LD HL,C000h						; source is start of sat buffer.

UpdateBuff_Loop:
	OUTI
	JR NZ,UpdateBuff_Loop
	RET

or:

	xor a
	di			; set VRAM address to 1800h
	out (99h),a		; lower byte 00
	ld a,1Bh + 040h		; upper byte 1Bh with flag to set the bus in write mode (1B00-1B7F VRAM: Sprite Attributes (128))
	ei
	out (99h),a		; note that this is protected by the ei instruction

	LD B,128 (127?)
	LD C,98h
	ld hl,C000h		; 128 byte Sprite Attributes Buffer in WRAM

loop:
	outi			; send the data (HL) to port 98h (podobnie jak w SMS mialem OTIR i byl problem, musialem OUTI uzyc wolniejsze)
	jp nz,loop		; the inner loop is exactly 29 cycles. If you are not in VBLANK this is the max speed for msx1.

Por ARTRAG

Enlighted (6889)

Imagen del ARTRAG

12-12-2021, 15:08

Both are correct but the second is better (faster)
JP nz is faster than JR nz when a jump occurs

Note that :
B as to be 128, not 127
you can load 128 in B while loading 98h in C using BC in this way
ld bc,8098h

Por sd_snatcher

Prophet (3594)

Imagen del sd_snatcher

12-12-2021, 15:14

siudym wrote:
	OUT (99h),A

Another tip is that the VDP I/O port must be obtained from the VDP.DR and VDP.RW values of the BIOS.

Por zeilemaker54

Champion (343)

Imagen del zeilemaker54

12-12-2021, 17:44

I am a little surprised that first thing you teach a beginning programmer is to bypass one of the foundations of the MSX standard, the BIOS. I think there is no need to do that, unless you want to squice 100% out of the hardware. But for a beginning programer this is not very important. Or am I missing something ?

Por ARTRAG

Enlighted (6889)

Imagen del ARTRAG

12-12-2021, 18:04

You miss reading. He asks to not use the BIOS

Por zeilemaker54

Champion (343)

Imagen del zeilemaker54

12-12-2021, 18:10

ARTRAG wrote:

You miss reading. He asks to not use the BIOS

Ok, I missed that. But I think we should advice against bypassing the BIOS, at least to beginning programers

Por siudym

Resident (39)

Imagen del siudym

12-12-2021, 23:42

I have no intention of bypassing the BIOS. I just wanted to know how to perform a given operation without itWink

Por ARTRAG

Enlighted (6889)

Imagen del ARTRAG

14-12-2021, 20:30

@siudym
this will work on any msx1 (and upper)

	xor a
	di			; set VRAM address to 1800h
	out (99h),a		; lower byte 00
	ld a,1Bh + 040h		; upper byte 1Bh with flag to set the bus in write mode (1B00-1B7F VRAM: Sprite Attributes (128))
	ei
	out (99h),a		; note that this is protected by the ei instruction

	ld bc,8098h
	ld hl,C000h		; 128 byte Sprite Attributes Buffer in WRAM

loop:
	outi			; send the data (HL) to port 98h 
	jp nz,loop		; the inner loop is exactly 29 cycles. 

Por siudym

Resident (39)

Imagen del siudym

13-12-2021, 16:21

The update satbuffer code works.

I would like to change the BACKGROUND color to black, but I have no idea how it works?

CHGCLR (0062H) *1
Function: changes the screen colour
Input:
A for the mode
FORCLR (F3E9H) for foreground color
BAKCLR (F3EAH) for background color
BDRCLR (F3EBH) for border colour
Output: none
Registers: all

ld a,colvalue?
call 0062H

What is "F3EBH"? Do I need to write value in this address?

I noticed that the sprite screen position starts with X. $ 20 on the left edge of the screen. The maximum value to the right is FF and it does not reach the right edge of the screen (mode0 / screen 1)
From what I can see the XY coordinates are 8 bits so I wonder how to set the sprite on the right edge of the screen?

Por theNestruo

Champion (386)

Imagen del theNestruo

13-12-2021, 16:49

BIOS routine CHGCLR uses FORCLR, BAKCLR and BDRCLR values.
Therefore, it is used like this:

    ld a, 12 ; dark green, for example
    ld (BDRCLR), a
    call CHGCLR

Please note that BDRCLR is applied immediately, and BAKCLR will be seen when you change screen mode (not sure if also in SCREEN 0/1). FORCLR makes sense in SCREEN 0/1 if you use BIOS routines to print text, for example.

Página 2/9
1 | | 3 | 4 | 5 | 6 | 7