Author Topic: redifine character set... something like on commodore64 or pcg on microbee  (Read 10155 times)

0 Members and 1 Guest are viewing this topic.

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Cobal. I seem to get an error message Segmentation fault (core dumped)I am not sure if I am doing something wrong.
   or I am missing something somewhere.
It is what I am after though...

DECLARE LIBRARY ".\Extensions\charset"
    SUB Charset_8x8 (BYVAL o AS _OFFSET)
    SUB Charset_8x16 (BYVAL o AS _OFFSET)
END DECLARE
DIM SHARED c16(7, 15, 255) AS _UNSIGNED _BYTE, charload AS _UNSIGNED _BYTE
CONST TRUE = -1, FALSE = NOT TRUE
 
 
 
loadreapingfont
Charset_8x16 (c16)
FOR i = 1 TO 255
    PRINT CHR$(i);
NEXT i
 
 
 
 
 
 
END
 
SUB loadreapingfont
    OPEN ".\FONT\char256.bin" FOR BINARY AS #1
    FOR c% = 0 TO 255
        FOR y% = 0 TO 15
            GET #1, , charload
            FOR x% = 0 TO 7 'STEP -1
                IF readbit(x%, charload) THEN c16(7 - x%, y%, c%) = 1 'any non-0 value should work
            NEXT
        NEXT
    NEXT
    CLOSE
END SUB
 
FUNCTION readbit (bit%, value%)
    IF value% AND 2 ^ bit% THEN readbit = TRUE ELSE readbit = FALSE
END FUNCTION
there is an 8x16 font set here to downloadwas only using to test, but goes into error
« Last Edit: August 28, 2018, 09:58:06 am by PMACKAY »
MackyWhite

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
I've never seen that error(or any other than file not found) before.
,But it looks like this line:

"Charset_8x16 (c16) "

try changing it to:

Charset_8x16 _OFFSET(c16(0, 0, 0))

and you should be good to go.

Just FYI, you can change the name of the loader if you want, LOADREAPINGFONT the game I was working on was Reaping the Dungeon and thats how that got its name, its a bit long but worked for the project.
« Last Edit: August 28, 2018, 10:52:07 am by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Cobal. I seem to get an error message Segmentation fault (core dumped)I am not sure if I am doing something wrong.
   or I am missing something somewhere.
It is what I am after though...

DECLARE LIBRARY ".\Extensions\charset"
    SUB Charset_8x8 (BYVAL o AS _OFFSET)
    SUB Charset_8x16 (BYVAL o AS _OFFSET)
END DECLARE
DIM SHARED c16(7, 15, 255) AS _UNSIGNED _BYTE, charload AS _UNSIGNED _BYTE
CONST TRUE = -1, FALSE = NOT TRUE
 
 
 
loadreapingfont
Charset_8x16 (c16)
FOR i = 1 TO 255
    PRINT CHR$(i);
NEXT i
 
 
 
 
 
 
END
 
SUB loadreapingfont
    OPEN ".\FONT\char256.bin" FOR BINARY AS #1
    FOR c% = 0 TO 255
        FOR y% = 0 TO 15
            GET #1, , charload
            FOR x% = 0 TO 7 'STEP -1
                IF readbit(x%, charload) THEN c16(7 - x%, y%, c%) = 1 'any non-0 value should work
            NEXT
        NEXT
    NEXT
    CLOSE
END SUB
 
FUNCTION readbit (bit%, value%)
    IF value% AND 2 ^ bit% THEN readbit = TRUE ELSE readbit = FALSE
END FUNCTION
there is an 8x16 font set here to downloadwas only using to test, but goes into error



Thank you cobalt... this works great. happy as a pig in mud :)
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Great stuff, I have ripped into the code and now works with 8x8 fonts.... Have also added.. Fonts were in reverse now fixed. this is just exactly what I wanted... Thank you heaps.


thank you every one for your input.


Now just to work out how to change the individual chars. (this is good). I understand it is in 8 bit string format, gets converted to binary then put in ram 1 bit at a time..
1+2+4+8+16+32+64+128 = 255 (easy old school stuff)

x^i,     funny i am stuffed for math but i can program :)
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Worked out... thank you
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Here is a look at the routine working
MackyWhite

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
that is looking really cool.
Granted after becoming radioactive I only have a half-life!

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
I have managed to get the game to feel like it multi tasks. So simple to add stuff now. Just a timer and animate does the rest. Thanks for the awesome .h


I was scared to use pset for drawing as the way i update my screen in the game... there is lots of speed to be had. So lots more stuff can be done.
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
In cobalt routine if you do a for i% = 0 to 15 step 2
If readbit
If readbit again with +1
Next i%

That will double the 8x8 into the 8x16

Or if you leave the second one out it will make it look like scanlines on an old tv. Pretty cool.

Remove the 7-x% (just have x%) and it will reverse the character data... eg mirror it or flip
« Last Edit: August 29, 2018, 11:12:55 am by PMACKAY »
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: redifine character set... something like on commodore64 or pcg on microbee
« Reply #24 on: September 15, 2018, 08:54:40 pm »
Just curious, is it possible to have charset.h make 16x16 and 32x32 chars. i know i can put characters together AB to give double width (16x16) but that uses two ASCII chars. can it work to give (a 16x16) rather than using two chars and losing a character.

AB
CD = 32 x 32 but I am wanting A = 32x32 (or at-least 16x16)

Pset works but I prefer AscII as much faster due to already programed in the system.

Wanting this as have a new idea for some different games.



MackyWhite

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: redifine character set... something like on commodore64 or pcg on microbee
« Reply #25 on: September 16, 2018, 12:09:41 am »
not sure, that would be a question for Galleon, he is the one that set this up for me way back when. But he is unfortunatly no longer a part of the team. Steve or Fellippe might be able to figure it out, at least they would be your best bet.
You may have to make a BMP(or PNG) and load it. then you could place the characters with _PUTIMAGE and have that make the characters 16x16 or 32x32 in a graphics mode though.
Granted after becoming radioactive I only have a half-life!