Shop OBEX P1 Docs P2 Docs Learn Events
Copying Font to RAM — Parallax Forums

Copying Font to RAM

marcwolfmarcwolf Posts: 38
edited 2011-04-21 16:21 in Propeller 1
I was wondering if it was possible to copy the ROM Font into RAM so one can then modify some of the characters.
For certain reasons I'd love to make the accented characters into something else.

Has anyone done something like that?
Many thanks
Dave

Comments

  • RaymanRayman Posts: 14,877
    edited 2011-03-25 08:03
    I've got some 2-bit and 1-bit bitmap utilities and code on my website that can do what I think you want...

    Copying the entire ROM Font can be done, but that would eat up a lot of memory...

    (As an aside, I'm starting work on a Flash Point driver that will hopefully let people use different fonts from external flash memory...)
  • localrogerlocalroger Posts: 3,452
    edited 2011-03-25 08:24
    As Rayman mentions it would take half of the Hub RAM to duplicate the whole ROM font. But another issue if you plan to use one of the regular drivers is that the tile drivers play some pretty subtle tricks to drop that bit in place to become the $8000 base address of the ROM font's usual location. Moving it to a copy at $4000 would require changing the initial tile value and possibly some mask values along the way, and those rotates and adds are *cough* poorly documented. It would be do-able but not as simple as just finding the $8000 and replacing it with $4000.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-25 10:32
  • marcwolfmarcwolf Posts: 38
    edited 2011-03-25 17:56
    Many many thanks Phil Your a saviour.

    With the ROM I was thinking of changing the accented characters to Inverse characters A-Z so I could achieve the effect of side by side windows and Labels/Values

    Thanks Raymon and LocalRoger of the advice. I'll be looking at the programs later to see how I can use them.

    Raymond - do you have a dump of the existing rom so I can copy and modify characters

    Many thanks for all of your help
    Dave
  • RaymanRayman Posts: 14,877
    edited 2011-03-25 18:10
    don't seem to have it as a binary file, but I have it as an image...
    RomFont.png
    256 x 256 - 9K
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-03-25 18:22
    If your only reason for doing this is changing the background and foreground colors why not just draw it the other way? Put your foreground color for 0 bits and your back ground for 1 bits (the opposite of what you normally do).
  • marcwolfmarcwolf Posts: 38
    edited 2011-03-25 18:23
    Hi Raymond
    Thanks for sharing but not quite what I need.
    The Prop has an internal ROM font and I want to copy that so I can generate my own characters to use with Phil's Backpack project. That way I can create a set of inverse single bit characters.

    Many thanks for sharing your talent thou
    Dave
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-03-25 18:28
    If you want a dump of the ROM font, why not use one of the existing terminal drivers to send it to a PC ZMODEM?
  • marcwolfmarcwolf Posts: 38
    edited 2011-03-26 07:43
    Hi Folks
    Ok - I have a ROM Dump of the area starting at $8000. Can some one give me a hint of how to decipher the interleaving so I can write a decoding program. I understand that its an 16x32 font so that will be 2 bytes per character row x 32 down. So that will be 64 bytes per character.

    Many thanks for all of your help.
    Dave
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-26 09:37
    If all you're doing is inverting things, you don't need to mess with the interleaving. Just copy the block of characters you want to invert from ROM to the upper RAM area you've reserved for custom characters, and invert all the bits.

    -Phil
  • potatoheadpotatohead Posts: 10,261
    edited 2011-03-26 10:33
    I'm going to answer the interleaving question, just because.

    The font is two bits per pixel, yielding 4 colors.

    00 = background
    01 = pixels unique to one character
    02 = pixels unique to the other character
    03 = pixels common to both.

    To display nothing, set all colors to the background. To display one character, set color 01 and 03 to the desired color for that character, and set 02 to the background. To display the other character, set color 02 and 03 to the desired display color, and set 01 to the background color.

    To invert, set the background color as the character color, and the desired character colors to the background color.
  • marcwolfmarcwolf Posts: 38
    edited 2011-03-26 16:10
    If all you're doing is inverting things, you don't need to mess with the interleaving. Just copy the block of characters you want to invert from ROM to the upper RAM area you've reserved for custom characters, and invert all the bits.

    -Phil

    Many thanks Phil.. I did not think of that approach and it would make it easier. Being a complete NewBee to the Prop (though I do program other processers) and with the information that PotatoHead kindly provided I should beable to work this out.

    I have looked throught the Overlay Spin code and I can see a function SetPair, so I could use that with a simple invert function, possibly even modify your code to give it the base address of the character(s) and get it to invert for me. Yes I know I will be grabbing 2 characters at a time but I can live with that.

    So in psuedo code it would be.

    AddrOfChar = $8000 ' Address of Char Pair I want to invert
    TempOfChar = $4000 ' Location to store inverted data
    For Pos = 0 to 31
    CharPart = Pointer(AddrOfChar + Pos) ' Get the ROM part
    Pointer(TempOfChar + Pos) = !CharPart ' Set the UserDef part
    Next Pos
    SetPair (xxxx, $4000) ' Send the UserDef part to the Overlay

    Now xxxx would be... Thats what I'm not sure of.

    Many thanks
    Dave
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-26 18:33
    Unfortunately, inserting formatting characters in the data stream, to be processed in real time, would compromise the delicate timing of the overlay code. Your best bet is still to use the custom glyph facility.

    -Phil
  • marcwolfmarcwolf Posts: 38
    edited 2011-03-26 22:04
    Hi Phil
    I am planning to use your custom Glyph function, but I noticed that you also had another function called
    SetPair which will accept characters pairs in the same format as the current Bitmap ROM.

    So to invert a character pair I would
    1. Goto the start of the character pair in the ROM
    2. Read in a byte
    3. Bitwise NOT the byte
    4. Save it in temp area
    5. Goto 2 until all bytes in character pair has been processed
    6. Call SetPair(XXXX, AddressofTemp)

    Now I am unsure of what I would put into XXXX

    Using the SetPair would mean I would not need to decode and then re-encode the character pair.

    Many thanks for your advice
    Dave
  • marcwolfmarcwolf Posts: 38
    edited 2011-04-21 16:21
    Hi Folks
    Been very busy with work and a costuming convention. I wrote a program to basically reverse engineer the Prop font and turn it into the glyph format that Phil Pilgrim used, exvept in reverse format. That way if you need to have certain characters in reverse you can

    This is a text file and should not be directly imported into the SPIN application, but rather cut and paste the characters you want.

    Hope this helps
    Dave
Sign In or Register to comment.