Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Demo/Graphics/32BitPaint.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ I0 DrawScreenChar(I64 x, I64 y, I64 char)
{
I64 i, j;

U8 *fontPointer = text.font(U8*) + (char & 0xFF) * FONT_HEIGHT;

for (i = 0; i < FONT_HEIGHT; i++)
for (j = 0; j < FONT_WIDTH; j++)
if ((text.font[char] >> (i * 8)) & (1 << j))
if (Bt(fontPointer, i * FONT_WIDTH + j))
DrawScreenPixel(x + j, y + i, BLACK32);
}

Expand Down
157 changes: 157 additions & 0 deletions src/Demo/Graphics/FontEd_8x12.ZC
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*After making a font...

You can save it as a binary file with:
FileWrite("filename.BIN.Z",text.font,256*FONT_HEIGHT);

You can load it with:
U64 *my_font=FileRead("filename.BIN.Z");
text.aux_font=my_font;

<CTRL-ALT-f> will toggle main font and aux_font.

If you want to change the system font permanently,
save to a file with this font editor program
and cut and paste the code into $LK,"::/Kernel/FontStd.HC"$.
You will need to recompile Kernel by calling $LK,"BootHDIns",A="MN:BootHDIns"$().

See $LK,"::/Demo/ExtChars.HC"$, $LK,"::/Demo/Games/CharDemo.HC"$,
$LK,"::/Demo/Graphics/CharAnimation.HC"$ and $LK,"::/Demo/ScrnCodes.HC"$.
*/

#define BLOW_UP_CHAR_X (18*FONT_WIDTH)
#define BLOW_UP_CHAR_Y (4*FONT_HEIGHT)

U8 cur_ch;
U8 *fp = text.font;

U0 DrawIt(CTask *task,CDC *dc)
{
I64 i,j,k,c;
TextPrint(task,0,0,BLUE<<4+YELLOW,"Press <CTRL-ALT-f> to Toggle Aux Font.");
k=0;
for (i=0; i<16; i++)
for (j=0; j<16; j++) {
if (k == cur_ch) {
if (Blink)
c= (BLACK<<4+YELLOW) <<8 + k++;
else
c=(YELLOW<<4+BLACK)<<8 + k++;
} else
c=(BLUE<<4+WHITE)<<8 + k++;
TextChar(task,,j,i+2,c);
}

k=0;
for (i=0;i<FONT_HEIGHT;i++)
for (j=0;j<FONT_WIDTH;j++) {

if (Bt(&fp[cur_ch * FONT_HEIGHT],k++))
dc->color=YELLOW;
else
dc->color=GREEN;
GrRect(dc, BLOW_UP_CHAR_X + j * FONT_WIDTH,
BLOW_UP_CHAR_Y+i*FONT_HEIGHT,
FONT_WIDTH,FONT_HEIGHT);
}
}

U0 FESave(Bool pmt)
{
U8 old_draw_it=Fs->draw_it;
CDoc *doc=DocNew;
I64 i, j;

for (i=0;i<256;i++) {
for (j = 0; j < FONT_HEIGHT; j++) {
DocPrint(doc,"0x%02X,", fp[i * FONT_HEIGHT + j]);
}
if (Bt(char_bmp_safe_dollar,i))
DocPrint(doc,"//%c",i);
else if (i=='$$')
DocPrint(doc,"//$$$$",i);
DocPrint(doc,"\n");
}
Fs->draw_it=NULL;
DocWrite(doc,pmt);
Fs->draw_it=old_draw_it;
DocDel(doc);
}

U0 FontEd()
{
I64 msg_code,arg1,arg2,k;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
MenuPush(
"File {"
" SaveAs(,CH_CTRLA);"
" Abort(,CH_SHIFT_ESC);"
" Exit(,CH_ESC);"
"}");
AutoComplete;
DocCursor;
DocClear;
Fs->win_inhibit|=WIG_DBL_CLICK;
cur_ch=0;
try {
Fs->draw_it=&DrawIt;
while (TRUE) {
switch (msg_code=MessageGet(&arg1,&arg2,
1<<MESSAGE_KEY_DOWN|1<<MESSAGE_MS_L_DOWN|1<<MESSAGE_MS_R_DOWN|1<<MESSAGE_MS_MOVE)) {
case MESSAGE_KEY_DOWN:
switch (arg1) {
case 0:
switch (arg2.u8[0]) {
case SC_CURSOR_LEFT:
cur_ch--;
break;
case SC_CURSOR_RIGHT:
cur_ch++;
break;
case SC_CURSOR_UP:
cur_ch-=16;
break;
case SC_CURSOR_DOWN:
cur_ch+=16;
break;

}
break;
goto fe_done;
case CH_CTRLA:
FESave(TRUE);
break;
case CH_ESC:
FESave(FALSE);
case CH_SHIFT_ESC:
goto fe_done;
default:
cur_ch=arg1;
}
break;
case MESSAGE_MS_L_DOWN:
case MESSAGE_MS_R_DOWN:
if (0<=arg1<FONT_WIDTH *16 && 0<=arg2-2*FONT_HEIGHT<FONT_HEIGHT*16) {
cur_ch=(arg2/FONT_HEIGHT-2)*16+arg1/FONT_WIDTH;
break;
} //fall through
case MESSAGE_MS_MOVE:
k=((arg2-BLOW_UP_CHAR_Y)/FONT_HEIGHT)*FONT_WIDTH+
(arg1-BLOW_UP_CHAR_X)/FONT_WIDTH;
if (0 <= k < FONT_WIDTH*FONT_HEIGHT) {
if (mouse.lb||msg_code==MESSAGE_MS_L_DOWN)
Bts(&fp[cur_ch * FONT_HEIGHT],k);
if (mouse.rb||msg_code==MESSAGE_MS_R_DOWN)
Btr(&fp[cur_ch * FONT_HEIGHT],k);
}
break;
}
}
fe_done:
MessageGet(,,1<<MESSAGE_KEY_UP);
} catch
PutExcept;
MenuPop;
SettingsPop;
}

FontEd;
14 changes: 7 additions & 7 deletions src/Kernel/Display.ZC
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
*/
I64 i, row, col, x, y;
U32 *framebuffer;
U64 ch_bitmap;

U64 nextRow = FONT_WIDTH - 1,
rowInc = sys_framebuffer_width - FONT_WIDTH;
U8 *fontPointer = text.font(U8*) + (ch & 0xFF) * FONT_HEIGHT;

if (!(text.raw_flags & RAWF_SHOW_DOLLAR))
{
if (ch == '$$')
Expand Down Expand Up @@ -69,20 +71,18 @@ See also $LK,"GrUpdateScreen",A="MN:GrUpdateScreen"$().
}
x = col * FONT_WIDTH;
y = row * FONT_HEIGHT;
ch_bitmap = text.font[ch & 0xFF];
framebuffer = text.fb_alias + sys_framebuffer_width * y + x;

PUSHFD
CLI
for (i = 0; i < FONT_WIDTH * FONT_HEIGHT; i++)
{
if (ch_bitmap & 1)
if (Bt(fontPointer, i))
*framebuffer++ = WHITE32;
else
*framebuffer++ = BLACK32;
if (i & (FONT_WIDTH - 1) == FONT_WIDTH - 1)
framebuffer += sys_framebuffer_width - FONT_WIDTH;
ch_bitmap >>= 1;
if (i & nextRow == nextRow)
framebuffer += rowInc;
}
POPFD
text.raw_col++;
Expand Down
Loading