Author Topic: Getting the system card font in HuC (with a sprinking of assembly)  (Read 1261 times)

nodtveidt

  • Guest
So this is just a lil test I whipped up last night because Tatsujin wants a Japanese port of Monolith... it'd be much easier to simply use the system card font than to try to do bitmap fonts for everything. Of course, HuC doesn't make this particularly easy, but luckily, since it allows for inline assembly, you can still do it with ease. :)

Code: [Select]
lda #$82 ; the high byte of the sjis code
sta <_ah
lda #$60 ; the low byte of the sjis code
sta <_al
lda #low(_bytebuffer)
sta <_bl
lda #high(_bytebuffer)
sta <_bh
lda #$00 ; set to $00 for 16x16 or $01 for 12x12
sta <_dh
jsr ex_getfnt
sta _returnval

bytebuffer is: char bytebuffer[32];
return val is: char returnval;
Both are globals for speed.

You can easily turn this code into a function by giving _ah, _al, and _dh variables instead of absolutes like I've done here. bytebuffer will contain the data of the one-bit-per-pixel character stored in the system card BIOS in either 16x16 or 12x12 size, depending on how you set _dh. If returnval is 1, then the call failed. You need to give it a proper Shift-JIS code to work. Decoding the buffer is easy too; it's a simple left-to-right pixel arrangement, with the highest bit containing the first pixel (decimal 128), the second highest bit containing the next pixel (decimal 64), etc. This goes on for 16 pixels, then goes on to the next line. So, bytebuffer[0] and bytebuffer[1] contain the pixels for the first line, bytebuffer[2] and bytebuffer[3] contain the pixels for the second line, etc etc etc until done.


nodtveidt

  • Guest
Re: Getting the system card font in HuC (with a sprinking of assembly)
« Reply #1 on: January 06, 2011, 09:55:45 AM »
A quick update to this... I was able to convert the 1-bit raster data to tile memory to be displayed on the screen. The only downside to the method I'm using is that there are only so many characters that can be placed on the screen at once using the technique I'm using right now; I've limited it to 2 lines of text. Exile has a two-line text limit and manages to pull it off, so this should work out just fine. So... things are moving alone just fine for now, and hopefully this will all work in the end.

EDIT: Yeap, it's gonna work in the end. :D

« Last Edit: January 06, 2011, 10:19:53 AM by The Old Rover »

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Getting the system card font in HuC (with a sprinking of assembly)
« Reply #2 on: January 06, 2011, 10:32:50 AM »
You can do what some games do and load 4 characters into the same VRAM location... and use 4 palettes to select the character needed.  (Well, this may even be how the chars are stored in the system card in the first place.)

nodtveidt

  • Guest
Re: Getting the system card font in HuC (with a sprinking of assembly)
« Reply #3 on: January 06, 2011, 03:35:02 PM »
Charles and I were jabbin' about that earlier on IRC... I'm not quite sure how to work that out though. :(

Punch

  • Hero Member
  • *****
  • Posts: 3278
Re: Getting the system card font in HuC (with a sprinking of assembly)
« Reply #4 on: March 05, 2019, 05:26:29 PM »
How I'm glad the Dev section was backed up and restored :D

Anyway, I was doing a bootloader (aka if Syscard good, load game, if not, show error screen) and I spent the whole day trying to write decent decoding and text plotting code and frankly it's not worth the effort. I'd rather use the 8x8 font that is preloaded by the System Cards into VRAM or use my own, non-SJIS one. :lol:

Still, a nice curiosity for those willing to encode their text directly into Shift-JIS for displaying.