Equivalent of INIGRP for Screen 4?

Por CodeIndigo

Supporter (16)

imagem de CodeIndigo

12-10-2021, 16:35

Pretty much exactly what it says in the title. I'm 99% of the way to getting some graphics on the screen by VRAM fills but I need to make sure I've initialized Screen 4 properly first. Can I just use INIGRP and set the sprite mode later, or is there a specific one for Screen 4 that I should be using?

Entrar ou registrar-se para comentar

Por MsxKun

Paragon (1038)

imagem de MsxKun

12-10-2021, 16:59

ld a,4 ; Screen number in A
call CHGMOD ; = $5F

Por CodeIndigo

Supporter (16)

imagem de CodeIndigo

12-10-2021, 17:32

Yeah, I'm doing that, and it only produces garbage on the screen.
The code below manages to fill the screen with the vertical lines, which is what I expect, but the VPOKE doesn't alter the screen at all.
What am I doing wrong? (Using Fr3el libraries in SDCC)

#define CHARADDR(x) (0x0008 * x)
#define SCREENADDR(row, col) (0x1800 + (0x20 * row) + col)

	CHGMOD(4); //this is a wrapper around that asm call
	FillVRAM(0x0000, 0x1800, 0x0F);
	FillVRAM(0x1800, 0x0200, 0x01);
	//flatten colors
	FillVRAM(0x2000, 0x1800, 0x1F);
	COLOR(WHITE, BLACK, BLACK);
	//diamond pattern
	CopyToVRAM((unsigned int)&cptn_a[0], CHARADDR(2), 32);
	//grin pattern
	CopyToVRAM((unsigned int)&cptn_b[0], CHARADDR(8), 32);
	
	//display diamond (?)
	VPOKE(SCREENADDR(4,2), 0x02);

Por MsxKun

Paragon (1038)

imagem de MsxKun

12-10-2021, 17:56

Well, no idea without looking at the final code that C code generates. No idea how those libraries access the VDP, if they use BIOS or not, but making a VPOKE is easier than a Fill or VRAM Copy. So it's probably a really silly thing U_U!

Por CodeIndigo

Supporter (16)

imagem de CodeIndigo

12-10-2021, 20:30

All of them use BIOS calls.

OK, then let's start with CHGMOD. I wrote that, so if there's anything wrong it's likely there.

	push AF
	push BC
	ld a, #_mode
	call #0x005F
	pop BC
	pop AF

FillVRAM: (from the Fr3el library)

  push IX
  ld   IX,#0
  add  IX,SP
      
  ld   L,4(IX) ; vaddress
  ld   H,5(IX)
    
  ld   C,6(IX) ;length
  ld   B,7(IX)
    
  ld   A,8(IX) ;value
  
  call FILVRM
    
  pop  IX
  ret

CopyToVRAM: (also from the Fr3el library)

  push IX
  ld   IX,#0
  add  IX,SP 

  ld   L,4(IX) ;ram address 
  ld   H,5(IX)
      
  ld   E,6(IX) ;VRAM address
  ld   D,7(IX)
  
  ld   C,8(IX) ;length
  ld   B,9(IX)
  
  call LDIRVM
  
  pop  IX
  ret

and VPOKE: (library)

  push IX
  ld   IX,#0
  add  IX,SP
  
  ld   L,4(IX) ;vaddress
  ld   H,5(IX)
   
  ld   A,6(IX) ;value
  
  call WRTVRM
  
  pop  IX
  ret

Does that help?

Por MsxKun

Paragon (1038)

imagem de MsxKun

12-10-2021, 21:29

Using BIOS should be safe. Then for Vpoke it's just:

ld hl,vram_address
ld a,byte
call WRTVRM

I see nothing very strange there, except the value(IX) that I guess it's the same as standard (IX+value)
So it must be something else, something like.. are you sure you have character data on the diamond chr you want to define?
Here: CopyToVRAM((unsigned int)&cptn_a[0], CHARADDR(2), 32);

Data definition is at cptn_a[0]? Is the data there correct? , why 32? 32 bytes? defining 4 chars?

Por CodeIndigo

Supporter (16)

imagem de CodeIndigo

12-10-2021, 21:32

I've checked the data being in RAM; yes, I'm defining four characters at a time. The data at cptn_a[0] is actually a const in the ROM space...

.............which might be why CopyToVRAM is failing, if it's looking in the explicit RAM section at that address. Gonna try that.

Por MsxKun

Paragon (1038)

imagem de MsxKun

12-10-2021, 21:43

Well, yes, about ROM space and that, dunno the size of your ROM, but if it's for example, 32ks and you didn't put the ROM address from $8000 to $BFFF into de Z80 space yet, it won't read it, of course.It will read RAM if there is RAM, or nothing.
In this case, the junk you said would make sense.

Por CodeIndigo

Supporter (16)

imagem de CodeIndigo

25-10-2021, 21:04

For the record, I solved this by just updating the VDP mode registers directly.