Problem for defining sprites in screen5 in assembler for MSX2

By gasparrini

Champion (335)

gasparrini さんの画像

19-03-2023, 14:57

Hello to all guys of the World of MSX,
Good day,

Problem for defining sprites in screen5 in assembler for MSX2, unfortunately the routine here under
it doesn't work as it should. Then I ask your help for me. I tried writing the routine, but something
is not working as it should.

So I ask for your intervention please.
Thanks in advance
Greetings
(^_^)
AG.

; ************************************************************
; sprites definition in screen5 in assembler for MSX2  
; ************************************************************


	.org	$DA00 - 7

	.db	$fe
	.dw	startProgram,endProgram,startProgram

startProgram:

LDIRVM	.equ $005c		; routine del BIOS usata per riempire la VRAM
CHGMOD	.equ $005f		; routine del BIOS usata per inizializzare lo schermo (V9938)

SPRTBL	.equ $7600+32    	; indirizzi tabelle definizione sprites
SPRCLR	.equ $7400		; indirizzi tabelle colore per sprites multicolore


;  ld a,0
;  call CHGMOD  ; SCREEN0   
  
  CALL	$CC			; key off
  LD HL,$F3B0 ; INDIRIZZO PER WIDTH (numero delle colonne da basic) 
  LD A,40     ; Valore per 40 Volonne FULL per SCREEN0
  LD (HL),A
   
 

  ld ix,$F3E9
  ld (ix+0),15	; colore primo piano
  ld (ix+1),1	; colore sfondo schermo
  ld (ix+2),1	; colore bordo dello schermo
  call $62		; chiama alla bios rom   
 
 
; Chiamata alla BIOS della ROM BASIC per CHGSND
; DEFUSR=&H135:A=USR(0) 
; ==============================================
; POKE&HF3DB,0:REM CHGSND OFF
; POKE&HF3DB,255:REM CHGSND ON
; ==============================================
; L'EQUIVALENTE IN BASIC SAREBBE: 
; SCREEN,,0:REM CHGSND OFF
; ==============================================
  
 XOR A
 LD ($F3DB),A   ; CLICKSW  CHGSND OFF
                ; IN BASIC EQUIVALE A SCREEN,,0  
                ; POKE&HF3DB,0:REM CHGSND OFF
                ; PER METTERE OFF IL BEEP DEL CURSORE


;M1 M2 M3 M4 M5  Screen format
;1  0  0  0  0   Text                            (BASIC SCREEN 0)
;0  0  0  0  0   Half text                       (BASIC SCREEN 1)
;0  0  1  0  0   Hi resolution                   (BASIC SCREEN 2)
;0  1  0  0  0   Multicolour                     (BASIC SCREEN 3)
;0  0  0  1  0   Scrn2 with 8 Sprites/Line       (BASIC SCREEN 4)
;0  0  1  1  0   256*212, 16  colours/pixel      (BASIC SCREEN 5)
;0  0  0  0  1   512*212, 4   colours/pixel      (BASIC SCREEN 6)
;0  0  1  0  1   512*212, 16  colours/pixel      (BASIC SCREEN 7)
;0  0  1  1  1   256*212, 256 colours/pixel      (BASIC SCREEN 8)
;1  0  0  1  0   80 column text screen           (BASIC SCREEN0, WIDTH 80)

;Register 0:
;Mode register 0
;bit  Name  Expl.
;0    D     External video input (0=input disable, 1=enable)
;1    M3    Mode M3
;2    M4    Mode M4 (Not on MSX 1)
;3    M5    Mode M5 (Not on MSX 1)
;4    IE1   Horizontal Retrace Interrupt Enable
;5    IE0   Vertical Retrace Interrupt Enable
;6    DG    DiGitize mode
;7    0     Always 0

;Register 1:
;Mode register 1
;bit  Name  Expl.
;0    MAG   Sprite zoom          (0=x1, 1=x2)
;1    SZ    Sprite size          (0=8x8, 1=16x16)
;2    0     Always 0 on MSX 1
;3    M2    Mode M2
;4    M1    Mode M1
;5    IE2   Interrupt control (50Hz (PAL),
;           60 Hz (NTSC) and Light pen/mouse on
;           MVDP colour bus)             (0=Disable, 1=Enable)
;6    BLK   Screen output control        (0=Disable, 1=Enable)
;7    416   VRAM size control            (0=4K, 1=16K)

  ld a,5
  call CHGMOD  ; SCREEN5  
 
 



; SCREEN,2 = VDP(1)=98 = SPRITE16X16
  ld a,98 ;224 ?
  out ($99),a
  ld a,1
  or 128	
  out ($99),a

 

; Inizializza i registri del VDP.
writeVDP:

	di
	push	af
	push	bc
	push	de
	push	hl
	


; ------------------------------------------------------------------------------

; PALETTE COLORS ROUTINE 
; =======================================
        LD    HL,TABEL	;select table palet
        CALL  PALETTE
        CALL INIT_START
; =======================================
PALETTE:
        DI

        LD    A,(HL)
        CP    0
        RET   Z
        INC   HL
        OUT   ($99),A
        LD    A,$90
        NOP
        NOP
        OUT   ($99),A
; ***************************************
        LD    A,(HL)
        INC   HL
        SLA   A
        SLA   A
        SLA   A
        SLA   A
        LD    B,A
        LD    A,(HL)
        INC   HL
        OR    B
        OUT   ($9A),A
        LD    A,(HL)
        OUT   ($9A),A
        INC   HL
        EI
        JR    PALETTE

TABEL:
    .DB 11,6,7,0   ; COLOR=(11,6,7,0)
    .DB 10,6,5,0   ; COLOR=(10,6,5,0)
    .DB 3,7,3,0    ; COLOR=(3,7,3,0)
    .DB 2,4,0,5    ; COLOR=(2,4,0,5)
END: 
    .DB 0,0,0,0	 ;stop make palette !!

INIT_START:


	 
; ------------------------------------------------------------------------------	

; Alloca la forma degli sprite
	ld	hl,SPRDEF
	ld	de,SPRTBL
	ld	bc,32*32
	call	LDIRVM	

; Alloca il colore degli sprite
	ld	hl,SPRCOLOR
	ld	de,SPRCLR
	ld	bc,16*0
	call	LDIRVM	


    ;
 pop hl
 pop de
 pop bc
 pop af
 ei
 RET ; Return to basic


SPRDEF:
; MAD HUNTER  Player1
  .DB 7,15,8,15,15,14,0,6,15,15,15,1,1,0,3,3,224,240,0,240,0,0,0,0,224,240,240,128,128,0,128,192
  .DB 0,0,7,0,0,1,7,1,0,0,0,14,14,7,0,0,0,0,240,0,208,208,240,224,0,0,0,112,112,224,0,0
  .DB 7,15,8,15,15,14,0,7,31,15,15,0,24,24,24,16,224,240,0,240,0,0,0,0,248,248,252,0,0,0,112,120
  .DB 0,0,7,0,0,1,7,0,0,48,48,15,7,6,0,0,0,0,240,0,208,208,240,224,6,6,0,248,248,112,0,0
  .DB 7,15,0,15,0,0,0,0,3,7,15,1,1,0,1,3,224,240,16,240,240,112,0,96,240,240,240,128,128,0,192,192
  .DB 0,0,15,0,11,11,15,7,0,0,0,14,14,7,0,0,0,0,224,0,0,128,224,128,0,0,0,112,112,224,0,0
  .DB 7,15,0,15,0,0,0,0,31,31,63,0,0,0,7,15,224,240,16,240,240,112,0,224,248,240,240,0,24,24,24,8
  .DB 0,0,15,0,11,11,15,7,96,96,0,15,15,7,0,0,0,0,224,0,0,128,224,0,0,12,12,240,224,32,0,0
; PORK
  .DB 0,3,15,27,60,56,24,4,3,15,31,7,59,37,18,12,0,128,224,176,120,56,48,64,128,224,240,240,240,224,112,248
  .DB 8,24,16,0,3,5,5,3,0,48,96,96,0,24,12,0,32,48,16,0,128,64,64,128,12,28,8,0,0,0,0,0
  .DB 0,3,15,27,60,56,24,4,3,15,31,31,31,15,7,15,0,128,224,176,120,56,48,64,128,224,240,240,236,210,36,152
  .DB 8,24,16,0,3,5,5,3,96,112,32,0,0,0,0,0,32,48,16,0,128,64,64,128,0,24,12,12,0,12,24,0
; FOX
  .DB 0,0,4,8,15,26,10,24,15,31,72,48,72,36,24,0,0,0,35,102,132,228,196,108,140,148,240,72,80,128,0,0
  .DB 8,8,16,23,48,32,48,34,16,96,55,7,51,25,1,3,128,128,128,128,0,0,0,128,0,096,0,128,128,0,192,224
  .DB 0,0,32,16,19,17,19,17,19,1,15,3,3,1,0,0,0,0,0,136,248,172,168,12,248,252,136,6,9,146,12,0
  .DB 2,2,70,38,44,46,44,38,32,46,32,48,24,28,7,15,16,16,48,112,0,0,0,160,0,2,112,240,230,76,0,128
; PENGUIN
  .DB 7,31,51,33,33,32,56,63,120,112,96,96,48,0,0,0,192,240,152,8,8,24,56,252,60,28,12,12,28,56,0,0
  .DB 0,0,12,18,18,28,0,0,7,15,31,31,15,1,0,0,0,0,96,48,48,96,0,0,192,224,240,240,224,192,0,0
  .DB 0,0,0,0,0,3,71,192,128,128,0,0,0,62,62,30,0,0,0,0,0,128,196,2,3,1,0,0,0,0,56,0
  .DB 3,15,25,16,16,16,28,63,60,56,48,48,56,28,0,0,224,248,204,132,132,4,28,252,30,14,6,6,12,0,0,0
  .DB 0,0,6,12,12,14,0,0,3,7,15,15,7,3,0,0,0,0,48,72,72,56,0,0,224,240,248,248,240,128,0,0
  .DB 0,0,0,0,0,1,35,64,192,128,0,0,0,0,28,0,0,0,0,0,0,192,226,3,1,1,0,0,0,124,124,120
; MOUSE POLICE
  .DB 0,1,3,0,7,0,0,0,48,124,15,6,31,31,14,0,0,128,192,0,224,0,0,0,12,254,240,220,248,248,0,0
  .DB 24,36,68,67,64,41,25,127,76,0,0,0,0,0,0,0,24,36,34,194,2,52,56,248,240,0,6,2,0,0,0,0
  .DB 0,24,56,60,56,22,4,0,3,0,0,9,0,0,0,30,0,24,28,60,28,200,128,0,0,1,1,33,7,7,0,0
  .DB 0,1,3,0,7,0,0,0,48,124,15,59,31,31,0,0,0,128,192,0,224,0,0,0,12,254,240,96,248,248,112,0
  .DB 24,36,68,67,64,41,25,31,12,0,96,64,0,0,0,0,24,36,34,194,2,52,56,254,242,0,0,0,0,0,0,0
  .DB 0,24,56,60,56,22,2,0,3,0,128,132,224,224,0,0,0,24,28,60,28,200,64,0,0,0,0,144,0,0,0,120
; CAT BOSS
  .DB 2,7,15,15,24,16,0,0,8,28,28,14,15,7,3,2,32,112,248,248,140,4,0,0,8,28,28,32,88,216,192,0
  .DB 0,0,0,0,0,15,63,31,6,2,34,97,0,24,28,12,0,0,0,0,0,120,254,252,243,34,32,88,164,36,56,0
  .DB 0,0,0,0,6,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,96,0,0,0,0,192,192,128,0,0,0,0
  .DB 2,7,15,15,24,16,0,0,8,28,28,2,13,13,1,0,32,112,248,248,140,4,0,0,8,28,28,56,120,248,128,0
  .DB 0,0,0,0,0,15,63,31,102,34,2,13,18,18,28,0,0,0,0,0,0,120,254,252,240,32,34,67,128,0,112,224
  .DB 0,0,0,0,6,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,96,0,0,0,0,192,192,128,0,0,0,0
  .DB 2,7,15,15,24,16,0,0,8,28,28,2,13,13,1,0,32,112,248,248,140,4,0,0,8,28,28,56,120,240,224,0
  .DB 0,0,0,0,0,15,63,31,103,34,2,13,18,18,14,0,0,0,0,0,0,120,254,252,176,32,34,67,128,12,28,56
  .DB 0,0,0,0,3,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,48,0,0,0,0,192,192,128,0,0,0,0
  .DB 2,7,15,15,24,16,0,0,8,28,28,14,15,15,0,0,32,112,248,248,140,4,0,0,8,28,28,32,88,216,192,0
  .DB 0,0,0,0,0,15,63,31,7,2,34,97,0,0,7,3,0,0,0,0,0,120,254,252,183,34,32,88,164,36,28,128
  .DB 0,0,0,0,3,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,48,0,0,0,0,192,192,128,0,0,0,0
; MARIO RED
  .DB 12,30,30,28,12,0,15,63,127,15,0,96,96,192,128,0,0,0,64,0,48,0,96,176,204,204,1,3,3,3,0,0
  .DB 0,0,0,0,0,0,0,0,0,0,15,31,31,31,15,6,0,0,0,0,0,0,128,64,48,48,240,252,252,252,0,0
  .DB 3,1,1,3,3,7,0,0,0,96,64,0,0,0,0,0,224,224,176,248,192,224,0,0,3,2,0,0,0,0,0,0
  .DB 12,30,30,28,12,0,7,15,30,29,30,15,4,16,24,14,0,0,64,0,48,0,96,176,192,192,192,0,0,0,48,60
  .DB 0,0,0,0,0,0,0,0,0,0,0,0,8,14,7,0,0,0,0,0,0,0,128,64,48,48,48,240,112,112,64,0
  .DB 3,1,1,3,3,3,0,0,0,0,0,0,3,1,0,0,224,224,176,248,192,224,0,0,0,0,8,8,128,128,0,0
  .DB 0,0,2,0,12,0,6,13,49,49,129,192,192,192,0,0,48,120,120,56,48,0,240,252,254,254,232,0,6,6,3,1
  .DB 0,0,0,0,0,0,1,2,14,14,14,63,63,63,0,0,0,0,0,0,0,0,0,0,0,0,0,224,248,248,240,96
  .DB 7,7,13,31,3,7,0,0,192,64,0,0,0,0,0,0,192,128,128,192,192,224,0,0,0,0,6,2,0,0,0,0
  .DB 0,0,4,0,12,0,6,13,3,3,3,0,0,0,14,62,48,120,120,56,48,0,240,248,188,220,188,120,16,4,12,56
  .DB 0,0,0,0,0,0,1,2,12,12,12,15,15,15,1,0,0,0,0,0,0,0,0,0,0,0,0,128,8,56,112,0
  .DB 7,7,11,31,3,7,0,0,0,0,16,16,0,0,0,0,192,128,128,192,192,224,0,0,0,0,0,0,224,192,0,0
; BAGS
  .DB 0,0,0,0,0,0,0,0,7,3,3,3,1,1,0,0,0,0,0,0,0,0,0,192,128,240,252,254,255,255,254,124
  .DB 0,0,0,0,0,0,0,3,1,15,63,127,255,255,127,62,0,0,0,0,0,0,0,0,224,192,192,192,128,128,0,0 
  
   
SPRCOLOR:


 endProgram:

.end
ログイン/登録して投稿

By Daemos

Prophet (2170)

Daemos さんの画像

20-03-2023, 12:11

Code is a mess. You keep interrupts on between outs to vdp and do all kinds of pushing and popping whiple doing calls and returns. You want a sprite on screen? You need to out the spritedata and out the spat to get something on screen. Are you 100% sure that your sprite data is sane?

By thegeps

Paragon (1260)

thegeps さんの画像

20-03-2023, 12:44

As always probably this isn't his own code (usually he ask someone else to do the work or find some snipets on web).
Infact he always post ALL the code instead the relevant part.
Anyway I think the problem is that he uses LDIRVM wich works well on MSX1 (I think he is trying to use some MSX1 code he already used on precuous msx1 games on msx2...)
The problem is: on screen5 you need to set reg14 bits to set VRAM address and LDIRVM, AFAIK, doesn't set it.
As always he is trying to do somethig he isn't able too, without studying ASM nor VDP...