Gedalya Posted September 29 Share Posted September 29 I am new to programming the Jaguar. I am testing things out and learning. I have a simple Hello World example I am working with: do vsync ' Sync to VBLANK and Update ALL RAPTOR objects jsfSetFontIndx(0) ' Set font style jsfSetFontSize(1) ' Set font size rapLocate 140,175 rapPrint "Hello World!" jsfLoadClut(strptr(BACKGROUND_clut),0,255) loop ' Loop around! What I am seeing is that without the jsfLoadClut line (without the background image) the "Hello World" text prints as white text; with the jsfLoadClut line included (with the background image) the text prints as a shade of blue. Why does the text change color? Or more to the point, how can I ensure the text stays the color I want. Quote Link to comment Share on other sites More sharing options...
+CyranoJ Posted September 30 Share Posted September 30 jsfLoadClut(strptr(BACKGROUND_clut),0,255) You are loading 256 colours. The font uses colours 240-256. 2 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted September 30 Author Share Posted September 30 45 minutes ago, CyranoJ said: jsfLoadClut(strptr(BACKGROUND_clut),0,255) You are loading 256 colours. The font uses colours 240-256. Thank you! Quote Link to comment Share on other sites More sharing options...
Gedalya Posted September 30 Author Share Posted September 30 To try and solve this issue I converted the image to 16 color palette (4bpp) and then the following: do vsync ' Sync to VBLANK and Update ALL RAPTOR objects jsfSetFontIndx(0) ' Set font style jsfSetFontSize(1) ' Set font size rapLocate 140,175 rapPrint "Hello World!" jsfLoadClut(strptr(BACKGROUND_clut),0,16) loop ' Loop around! With the following entry in rapinit.s: ; BACKGROUND dc.l 1 ; (REPEAT COUNTER) ; Create this many objects of this type (or 1 for a single object) dc.l is_active ; sprite_active ; sprite active flag dc.w 0,0 ; sprite_x ; 16.16 x value to position at dc.w 0,0 ; sprite_y ; 16.16 y value to position at dc.w 0,0 ; sprite_xadd ; 16.16 x addition for sprite movement dc.w 0,0 ; sprite_yadd ; 16.16 y addition for sprite movement dc.l 352 ; sprite_width ; width of sprite (in pixels) dc.l 240 ; sprite_height ; height of sprite (in pixels) dc.l is_normal ; sprite_flip ; flag for mirroring data left<>right dc.l 0 ; sprite_coffx ; x offset from center for collision box center dc.l 0 ; sprite_coffy ; y offset from center for collision box center dc.l 352/2 ; sprite_hbox ; width of collision box dc.l 240/2 ; sprite_vbox ; height of collision box dc.l BACKGROUND ; sprite_gfxbase ; start of bitmap data dc.l 4 ; (BIT DEPTH) ; bitmap depth (1/2/4/8/16/24) dc.l is_RGB ; (CRY/RGB) ; bitmap GFX type dc.l is_opaque ; (TRANSPARENCY) ; bitmap TRANS flag dc.l 352*240 ; sprite_framesz ; size per frame in bytes of sprite data dc.l 352 ; sprite_bytewid ; width in bytes of one line of sprite data dc.l 0 ; sprite_animspd ; frame delay between animation changes dc.l 0 ; sprite_maxframe ; number of frames in animation chain dc.l ani_rept ; sprite_animloop ; repeat or play once dc.l edge_wrap ; sprite_wrap ; wrap on screen exit, or remove dc.l spr_inf ; sprite_timer ; frames sprite is active for (or spr_inf) dc.l spr_linear ; sprite_track ; use 16.16 xadd/yadd or point to 16.16 x/y table dc.l 0 ; sprite_tracktop ; pointer to loop point in track table (if used) dc.l spr_unscale ; sprite_scaled ; flag for scaleable object dc.l %00100000 ; sprite_scale_x ; x scale factor (if scaled) dc.l %00100000 ; sprite_scale_y ; y scale factor (if scaled) dc.l -1 ; sprite_was_hit ; initially flagged as not hit dc.l no_CLUT ; sprite_CLUT ; no_CLUT (8/16/24 bit) or CLUT (1/2/4 bit) dc.l cant_hit ; sprite_colchk ; if sprite can collide with another dc.l cd_keep ; sprite_remhit ; flag to remove (or keep) on collision dc.l single ; sprite_bboxlink ; single for normal bounding box, else pointer to table dc.l 1 ; sprite_hitpoint ; Hitpoints before death dc.l 2 ; sprite_damage ; Hitpoints deducted from target dc.l 352 ; sprite_gwidth ; GFX width (of data) The color issue is resolved but now the image is skewed: @CyranoJ, is there anything obviously wrong with what I am trying to do? Thanks! Quote Link to comment Share on other sites More sharing options...
Sporadic Posted September 30 Share Posted September 30 (edited) The sprite_CLUT in your object definition should really be 0 since your jsfLoadClut is loading the 16 colours into CLUT 0. That wouldn't cause the corruption though (unless the no_clut is actually causing it).. Perhaps post your assets txt entry and also the actual image you are displaying so they can be checked. Edited September 30 by Sporadic 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted September 30 Author Share Posted September 30 4 minutes ago, Sporadic said: The sprite_CLUT in your object definition should really be 0 since your jsfLoadClit is loading the 16 colours into CLUT 0. That wouldn't cause the corruption though (unless the no_clut is actually causing it).. Perhaps post your assets txt entry and also the actual image you are displaying so they can be checked. @Sporadic thank you. This is the assets entry: ABS,BACKGROUND,gfx_clut8,ASSETS\GFX\background.bmp ABS,BACKGROUND,gfx_clut8,ASSETS\GFX\background.bmp I have tried several different background images, here is one of them attached to this post: background.bmp Quote Link to comment Share on other sites More sharing options...
Sporadic Posted September 30 Share Posted September 30 You just want gfx_clut in there, no 8 on the end 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted September 30 Author Share Posted September 30 31 minutes ago, Sporadic said: You just want gfx_clut in there, no 8 on the end Thank you @Sporadic! I'm still seeing the issue but I feel like my code is slowly getting cleaned up. Regarding the use of gfx_clut vs gfx_clut8, what is the difference? I presume from reading the notes in assets.txt that gfx_clut8 is for 8-bit images, the one I am using in GIMP is labeled as "Indexed color 8-bit gamma integer." so I just assumed gfx_clut8 was the right choice. Quote Link to comment Share on other sites More sharing options...
Sporadic Posted September 30 Share Posted September 30 (edited) There is no gfx_clut8. For 1,2,4 or 8 bit palette images, just use gfx_clut. That will create the clut index asset for you. Then as you have done, in the object definition you tell it the bit depth you're using. For a 16-bit image, just use gfx_clut16. I'm not in a position to check your graphic file at preset to confirm it's 4bit. I couldn't spot anything else wrong though. "For graphics conversion you can use "gfx_clut" or "gfx_noclut" to convert a .BMP file into jaguar raw format and optionally export the paletter or not (clut=yes, noclut=no). ' This applies to 1-, 2-, 4- and 8-bit graphics only. ' For 16-bit and 24-bit graphics no clut is created (because there isn't a need for one). ' Finally for 16-bit images you have to use gfx_clut16 or gfx_noclut16." EDIT: I've just noticed in your original post that you said it was 4bits (16 colour). But in your later post you said you used "Indexed color 8-bit". Which would be a 256 colour 8 bit image. If it is 8bit, then you still need gfx_clut in assets, but your object definition would be wrong. You need to put 8 in the bitdepth and remove the /2 in all the "size" properties. LoadClut would also need adjusting to 256. This should be detailed in the rapinit.s sample object and in the documentation in the docs folder. Edited September 30 by Sporadic 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted September 30 Author Share Posted September 30 33 minutes ago, Sporadic said: There is no gfx_clut8. For 1,2,4 or 8 bit palette images, just use gfx_clut. That will create the clut index asset for you. Then as you have done, in the object definition you tell it the bit depth you're using. For a 16-bit image, just use gfx_clut16. I'm not in a position to check your graphic file at preset to confirm it's 4bit. I couldn't spot anything else wrong though. "For graphics conversion you can use "gfx_clut" or "gfx_noclut" to convert a .BMP file into jaguar raw format and optionally export the paletter or not (clut=yes, noclut=no). ' This applies to 1-, 2-, 4- and 8-bit graphics only. ' For 16-bit and 24-bit graphics no clut is created (because there isn't a need for one). ' Finally for 16-bit images you have to use gfx_clut16 or gfx_noclut16." EDIT: I've just noticed in your original post that you said it was 4bits (16 colour). But in your later post you said you used "Indexed color 8-bit". Which would be a 256 colour 8 bit image. If it is 8bit, then you still need gfx_clut in assets, but your object definition would be wrong. You need to put 8 in the bitdepth and remove the /2 in all the "size" properties. LoadClut would also need adjusting to 256. This should be detailed in the rapinit.s sample object and in the documentation in the docs folder. Thank you @Sporadic that makes sense. Regarding the format of the image, I believe it is correct but I cannot say with certainty as I lack the experience. This is the image properties in GIMP: I have another program I use which says of the same file that it is 4bpp (16 colors). Quote Link to comment Share on other sites More sharing options...
+CyranoJ Posted September 30 Share Posted September 30 Use XnView32 or PSP 6 / PSP 7 to load and save it - then try again. 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 1 Author Share Posted October 1 Thank you @CyranoJ. This is where I have it now; it is printing the image correctly but it takes up only 1/2 of the screen leaving the rest a mess. Quote Link to comment Share on other sites More sharing options...
+CyranoJ Posted October 1 Share Posted October 1 dc.l 352 ; sprite_bytewid ; width in bytes of one line of sprite data dc.l 352 ; sprite_gwidth ; GFX width (of data) bytewid and gwidth are wrong - they need /2 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 1 Author Share Posted October 1 24 minutes ago, CyranoJ said: dc.l 352 ; sprite_bytewid ; width in bytes of one line of sprite data dc.l 352 ; sprite_gwidth ; GFX width (of data) bytewid and gwidth are wrong - they need /2 Thank you! Thats fixed it! Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 1 Author Share Posted October 1 @CyranoJ would those changes look different for a 1bpp monochrome image? Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 1 Author Share Posted October 1 Aside from the bit depth being 1 I mean. Quote Link to comment Share on other sites More sharing options...
Sporadic Posted October 1 Share Posted October 1 The rapinit.s file should have an example object that lists the relevant changes you need to make. If not, then look at that file in some of the examples. It should tell you where to put a /2 or /4 or *2 etc etc. If you can't find it then I'll paste it in here when next at the computer. 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 1 Author Share Posted October 1 34 minutes ago, Sporadic said: The rapinit.s file should have an example object that lists the relevant changes you need to make. If not, then look at that file in some of the examples. It should tell you where to put a /2 or /4 or *2 etc etc. If you can't find it then I'll paste it in here when next at the computer. Thank you! I see what you are referring to. 1 Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 3 Author Share Posted October 3 After some learning on my part I have had some success working with a number of images including (I am pleased to say) animated images. The only part I seem to be tripping on is with a 1bpp monochrome image I am attempting to use. Is there a gotcha I am not aware of for working with a monochrome image? The settings seem easy enough to figure it with respect to rapinit.s: ; SHIPSELECTED dc.l 1 ; (REPEAT COUNTER) ; Create this many objects of this type (or 1 for a single object) dc.l is_active ; sprite_active ; sprite active flag dc.w 0,0 ; sprite_x ; 16.16 x value to position at dc.w -48,0 ; sprite_y ; 16.16 y value to position at dc.w 0,0 ; sprite_xadd ; 16.16 x addition for sprite movement dc.w 0,0 ; sprite_yadd ; 16.16 y addition for sprite movement dc.l 48 ; sprite_width ; width of sprite (in pixels) dc.l 48 ; sprite_height ; height of sprite (in pixels) dc.l is_normal ; sprite_flip ; flag for mirroring data left<>right dc.l 0 ; sprite_coffx ; x offset from center for collision box center dc.l 0 ; sprite_coffy ; y offset from center for collision box center dc.l 48/2 ; sprite_hbox ; width of collision box dc.l 48/2 ; sprite_vbox ; height of collision box dc.l SHIPSELECTED ; sprite_gfxbase ; start of bitmap data dc.l 1 ; (BIT DEPTH) ; bitmap depth (1/2/4/8/16/24) dc.l is_RGB ; (CRY/RGB) ; bitmap GFX type dc.l is_trans ; (TRANSPARENCY) ; bitmap TRANS flag dc.l 48*48/8 ; sprite_framesz ; size per frame in bytes of sprite data dc.l 48/8 ; sprite_bytewid ; width in bytes of one line of sprite data dc.l 2 ; sprite_animspd ; frame delay between animation changes dc.l 1 ; sprite_maxframe ; number of frames in animation chain dc.l ani_rept ; sprite_animloop ; repeat or play once dc.l edge_wrap ; sprite_wrap ; wrap on screen exit, or remove dc.l spr_inf ; sprite_timer ; frames sprite is active for (or spr_inf) dc.l spr_linear ; sprite_track ; use 16.16 xadd/yadd or point to 16.16 x/y table dc.l 0 ; sprite_tracktop ; pointer to loop point in track table (if used) dc.l spr_unscale ; sprite_scaled ; flag for scaleable object dc.l %00100000 ; sprite_scale_x ; x scale factor (if scaled) dc.l %00100000 ; sprite_scale_y ; y scale factor (if scaled) dc.l -1 ; sprite_was_hit ; initially flagged as not hit dc.l 1 ; sprite_CLUT ; no_CLUT (8/16/24 bit) or CLUT (1/2/4 bit) dc.l cant_hit ; sprite_colchk ; if sprite can collide with another dc.l cd_keep ; sprite_remhit ; flag to remove (or keep) on collision dc.l single ; sprite_bboxlink ; single for normal bounding box, else pointer to table dc.l 1 ; sprite_hitpoint ; Hitpoints before death dc.l 2 ; sprite_damage ; Hitpoints deducted from target dc.l 48/8 ; sprite_gwidth ; GFX width (of data) The image itself is simple enough: shipselected.bmp Quote Link to comment Share on other sites More sharing options...
+CyranoJ Posted October 3 Share Posted October 3 Min size is a phrase, which is 64 bits. So 48 won't work as a width. Quote Link to comment Share on other sites More sharing options...
Gedalya Posted October 3 Author Share Posted October 3 13 hours ago, CyranoJ said: Min size is a phrase, which is 64 bits. So 48 won't work as a width. Thank you! It sounds like the image needs to be reworked to be larger; is that correct? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.