noob asm5900 prob

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
..::[carsten]::..
Posts: 6
Joined: Thu Jan 06, 2005 2:09 am

noob asm5900 prob

Post by ..::[carsten]::.. »

hi,
i am new to ps2dev. i coded the following with asm5900 and ps2lib20.
it only shows a red frame at the tv`s borders:

Code: Select all

TARGET ELF, R5900

code SEGMENT 0x400000
     ASSIGN pc:code.main, gp:0x432101, sp:0x123454

INCLUDE "..\ps2lib\macros.inc"
INCLUDE "..\ps2lib\equates.inc"
INCLUDE "..\ps2lib\syscalls.inc"
INCLUDE "..\ps2lib\dma.inc"
INCLUDE "..\ps2lib\gif.inc"
INCLUDE "..\ps2lib\gs.inc"

SCREEN_W EQU 384
SCREEN_H EQU 256
SCREEN_M EQU 7

main PROC
        subi sp, 0x200
        jal Dma02Reset
        nop
        
        addiu a0, zero, NON_INTERLACED
        addiu a1, zero, PAL
        addiu a2, zero, FRAME
        jal GsInit
        nop
        
        addiu a0, zero, SCREEN_W
        addiu a1, zero, SCREEN_H
        addiu a2, zero, PSMCT32
        addiu a3, zero, SCREEN_M
        jal GsSetVideoMode
        nop
        
;following draws a red rect at tv's borders!??
;                          B       G      R
        addi a1, zero, 0
        sll a1, a1, 16
        addi a2, zero, 0
        sll a2, a2, 8
        addi a3, zero, 255
        sll a3, a3, 0
        or a0, a1, a2
        or a0, a0, a3
        jal GsSetBgColor
        nop

        j $

main ENDP
GIF_DECLARE_PACKET gif, 0x00
code ENDS
END code.main
thx inadvance
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

the color for GsSetBgColor goes into v0 not a0 (dont know why, should actually be a0). then it works (already tested) ;)


and by the way, why do all newbies have to write that they are "noobs" into the title? if they realy want to inform everyone that they are noobs, isnt it sufficient to write it into the post itself?
infj
..::[carsten]::..
Posts: 6
Joined: Thu Jan 06, 2005 2:09 am

Post by ..::[carsten]::.. »

works ine now ;) thanks

ps:i will never write it again, promised!
..::[carsten]::..
Posts: 6
Joined: Thu Jan 06, 2005 2:09 am

Post by ..::[carsten]::.. »

it worked only once...
after a recompiling it shows the rect again!?

when i take a look at the GsSetBgColor proc in gs.inc it takes the color in a0. so what is the prob now???

thanks in advance

..::[carsten]::..
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

just to simplify that piece of code ( li is a macro and should be in macros.inc )

li a0, 0x0000FF
jal GsSetBgColor
nop

wait:
j wait
nop

this should work, afair from wiRe's ps2lib, but it was a long time I looked at it.
Kung VU
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

maybe we have different versions of the gs.inc, but mine ("GS Lib v2.0") takes the color in v0

Code: Select all

; desc: change background color
; in&#58; v0 = background color &#40;&#40;B<<16&#41;|&#40;G<<8&#41;|&#40;R<<0&#41;&#41;
; waste&#58; at
GsSetBgColor    PROC
                li          at, GS_REG
                sd          v0, 0xE0&#40;at&#41;
                jr          ra
                nop
GsSetBgColor    ENDP
after a recompiling it shows the rect again!?
i dont understand that question o_O
infj
..::[carsten]::..
Posts: 6
Joined: Thu Jan 06, 2005 2:09 am

Post by ..::[carsten]::.. »

i think i downloaded my version at wire's page. may mail me yours? hopefully it works afterwards...
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

i also dont know where mine is from, so i just checked the one from wire's page and its different, seems like mine is older.
i tested your code with the new one (with color in a0) - still works.

so when you set the color in a0 it doesnt work? or what exactly is your problem now?
infj
..::[carsten]::..
Posts: 6
Joined: Thu Jan 06, 2005 2:09 am

Post by ..::[carsten]::.. »

my GsSetBgColor takes the color in a0 (look at gs.inc). the code i posted should change the bgcolor to red, but it only draws a red rect at the borders of the tv!? i also tried out an older version (1.3 i think), which takes color in v0, but there is the same problem...
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

ah, now i understand your problem. actually it not a problem, the program works as it should. the borders of the tv are the "background".
if you want to make the whole screen red for example you have to draw something on it. the easiest way i think would be to draw a sprite.

try add this to your program instead of the SetBgColor code:

Code: Select all

	la          at, gif_packet|0x20000000       ; uncached mem
	addi        v0, zero, SCREEN_W
	sll         v0, v0, 4
	ori         v0, 0x8000
	sh          v0, gif_packet.~cls_xy+0&#40;at&#41;
	addi        v0, zero, SCREEN_H
	sll         v0, v0, 4
	ori         v0, 0x8000
	sh          v0, gif_packet.~cls_xy+2&#40;at&#41;

	la          a0, gif_packet                  ; send the gif
	jal         Dma02SendGif
	addiu       a1, zero, gif_packet._size/16

	wait&#58; 
	j wait 
	nop  

	gif_packet	TABLE ALIGN 16
cls&#58;		GIF_TAG     4, 1, 0, 0, 0, 1, GIF_AD
		GIF_DATA    GS_PRIM, PRIM_SPRITE
		GIF_DATA    GS_RGBAQ, 0x800000ff ;RED
		GIF_DATA    GS_XYZ2, 0
cls_xy&#58;		GIF_DATA    GS_XYZ2, 0
	gif_packet	ENDT
infj
..::[carsten]::..
Posts: 6
Joined: Thu Jan 06, 2005 2:09 am

Post by ..::[carsten]::.. »

that's confusing...
why is this proc called setbgcolor if it does not set thebackground's color????

thanks
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

The background on a TV is the border, because the space in the middle of the TV is the foreground.

Definition of background: The area of the C64 screen in which programmers are not allowed to draw yet do it anyways. (I think thats how the saying goes...)
Shoot Pixels Not People!
Makeshift Development
Post Reply