IMAGE Font load section

SGDK only sub forum

Moderator: Stef

Post Reply
matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

IMAGE Font load section

Post by matteus » Thu Apr 20, 2017 10:36 pm

I've an image of 416x16 which contains 16x16 letters of a font.

IMAGE font "Images/font.png" NONE

I want to load a series of 16x16 sections of this IMAGE onto plan A? What functions would I use?

MrTamk1s
Very interested
Posts: 75
Joined: Sun Jan 04, 2015 10:27 pm
Location: Pennsylvania
Contact:

Re: IMAGE Font load section

Post by MrTamk1s » Fri Apr 21, 2017 5:19 am

TMK, the easiest thing to do would be to just resize your letters to single 8x8 px tiles (like SGDK's normal default font), and upload to VRAM the image's tiles to overwrite the default SGDK font. Take a look at VRAM in the debuggers of Gens KMod/your emulator to get the base VRAM addr offset to use for the upload addr.

After overwriting the font, any of the string printing functions would use the new font's tiles. (VDP_drawText, VDP_drawTextBG, etc). To restore the old font, just do the same upload thing but using an image with the default SGDK font.
Attachments
SGDK_DefaultFont.png
SGDK_DefaultFont.png (710 Bytes) Viewed 7731 times
SGDK homebrew dev and Unity3D Indie dev.
Sega does what Nintendont!

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: IMAGE Font load section

Post by matteus » Fri Apr 21, 2017 7:57 am

Thanks for the response :) I know this trick already! But wanting a bigger font set too, so need to work this out :D

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: IMAGE Font load section

Post by Stef » Fri Apr 21, 2017 8:47 am

If you want to use bigger font then you have to rewrite your own drawText(..) methods to take care of the 2x2 tiles letters, a big deal honestly !

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: IMAGE Font load section

Post by matteus » Sat Apr 22, 2017 10:48 am

I know stef :) I'm not really explaining myself properly here! All I want to do is take a number of tiles from an image and load them to a plan :)

So for example say image1 has 8 tiles. I'd like to load tiles 1 and 8 to the screen next to each other :)

1 2 3
6 7 8

Would it be easier to just have a number of individual images of 16x16?

IMAGE letterA
IMAGE letterB

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: IMAGE Font load section

Post by Stef » Sat Apr 22, 2017 8:20 pm

Do you had a look on the VDP_setMapEx(..) method ? I think that's what you need :)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: IMAGE Font load section

Post by matteus » Sun Apr 23, 2017 10:07 am

I'll take a look at it :) Thanks Stef!

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: IMAGE Font load section

Post by matteus » Mon Apr 24, 2017 2:51 pm

Stef wrote:Do you had a look on the VDP_setMapEx(..) method ? I think that's what you need :)
I can't get this to work! I declare the image as a map in my resources and it says "map" not yet supported?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: IMAGE Font load section

Post by Stef » Mon Apr 24, 2017 6:12 pm

Declare it as an IMAGE, internally the image contains a map : image->map
:)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: IMAGE Font load section

Post by matteus » Tue Apr 25, 2017 8:55 pm

Sorry I'm still struggling could you write me an example? :)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Re: IMAGE Font load section

Post by matteus » Tue Apr 25, 2017 9:30 pm

okay worked it out :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: IMAGE Font load section

Post by Stef » Wed Apr 26, 2017 9:15 am

Well done ;)

Post Reply