Displaying sprites in screen 5

Por Driehoogvoor

Resident (52)

Imagen del Driehoogvoor

13-08-2014, 12:38

I'm having a hard time displaying sprites in screen 5. I can do it in screen 2, by setting the pattern in address #3800 and the attributes (y, x, pattern number, color) in #1B00. The address information comes from Konamiman's MSX2 Technical Handbook. Alright—so far, so good.

Now for screen 5. According to the handbook, the sprite pattern should be stored in #7A00, the attributes (y x, pattern number, not used) in #7600, and the color in address #7400 (per sprite line, so 16 positions, of which only the first 8 will be used when displaying 8x8 sprites).

When I do these modifications on my working screen 2 code, I only see some minor garbage on the left side of my screen, in the middle. There's a red pixel and a white one. I've googled a lot, and tried many things—I've tried clearing the sprite memory first with both BIOS call #69 and manually writing zeros into the sprite VRAM, I've tried different addresses (the V9938 Technical Data Book and the MSX2 Machinetaal Handboek both specified different VRAM locations), reading the pattern and attribute addresses from BIOS calls #81 and #84, but nothing seems to work.

Any help would be really welcome. Thanks!

Login sesión o register para postear comentarios

Por hit9918

Prophet (2911)

Imagen del hit9918

13-08-2014, 14:32

I got hit by this too, mysterious problem.
In my sources I find doing an OR 7 before storing the value to R5.
That register has some mask bits asking to be set to 1.

Brainstorming. What could be the sense of these mask bits.
Maybe mask the colorbytes address, then have less colorbytes to handle.
But as far as I remember sprites just disappear on emu, like coordinate SAT address too gets masked.
I dont know what the real 9938 does.

Por The_Engineer

Master (177)

Imagen del The_Engineer

13-08-2014, 14:54

The default settings for screen 5 are:
0x7400 color table
0x7600 attribute table
0x7800 pattern table

Not sure why you are referring to 0x7A00.

Por Driehoogvoor

Resident (52)

Imagen del Driehoogvoor

13-08-2014, 15:16

The #7A00 is from both the V9938 Technical Data Book as the MSX2 Technical Handbook. I've tried using #7800 too, but I've yet to make it work. Here's the code I'm using:

               ORG #4000

WRTVDP         EQU #0047
WRTVRM         EQU #004D
FILVRM         EQU #0056

               LD A,5
               CALL #5F

               ; Pattern

               LD A,#FF
               LD HL,#7800
               LD BC,32
               CALL FILVRM

               ; Colors

               LD A,#0F
               LD HL,#7400
               LD BC,16
               CALL FILVRM

               ; Attributes

               LD HL,#7600
               LD A,20
               CALL WRTVRM

               INC HL
               LD A,120
               CALL WRTVRM

               INC HL
               XOR A
               CALL WRTVRM

               ; Wait for CTRL+STOP

WAIT           CALL #B7
               JR NC, STOP

               XOR A
               CALL #5F


Por kanima

Master (194)

Imagen del kanima

13-08-2014, 16:07

WRTVRM is only for MSX 1 screens as it only uses the lower 14-bits of the address. To write to a 16-bit address use NWRVRM (#0177). Same problem with FILVRM, use BIGFIL (#016B) instead.
P.S. #7800 looks to be the right address for the pattern table.

Por AxelF

Champion (391)

Imagen del AxelF

13-08-2014, 18:19

The #4D BIOS call (WRTVRM) is limited to adress #3FFF.

If you want to write above that adress,
you have to change VDP Register #14 to set the BASE adress
Then set the VDP pointer, and then write data to the VDP...

xxxxx000 = #0000
xxxxx001 = #4000
xxxxx010 = #8000
xxxxx011 = #C000
xxxxx100 = #10000
xxxxx101 = #14000
xxxxx110 = #18000
xxxxx111 = #1C000

; Set register #14
LD    A,1   ; Base adress #4000
OUT   (#99),A
LD    A,14 + 128 ; Write regster #14 (BIT 7 is set for writing)
OUT   (#99),A

Por Driehoogvoor

Resident (52)

Imagen del Driehoogvoor

13-08-2014, 16:34

Thanks, guys! That worked like a charm! Smile

I used the WRITE_VRAM routine that I wrote for the star field (see my other topic). That routine readies the VRAM for writing on address AHL. Instead of FILVRM, I just DJNZ some OUT statements now, and now I'm looking at my beautiful square sprite.

Now the hard part, remembering what I was trying to make that needed a sprite...

Por Driehoogvoor

Resident (52)

Imagen del Driehoogvoor

14-08-2014, 22:33

Alright, step one complete! A walking player sprite (it can be controlled with the left and right cursor keys). Here's the source. The name 'error' is from a game I'm making in JavaScript, called I Am Error (yes, a Zelda 2 reference), as is the player sprite and the Game Boy-esque color scheme. Smile