Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > CSDb Entries > Release id #163421 : Smallest We Can [30 bytes]
2018-04-01 12:44
Pex Mahoney Tufvesson

Registered: Sep 2003
Posts: 50
Release id #163421 : Smallest We Can [30 bytes]

When trying to make the font creation even smaller than 39 bytes, I decided to put parts of the code into the filename.

Since the 128b compo clearly states that the entry is to be handed in as prg, the filenames needs to be Win/linux/osx compatible:

OSX is pretty forgiving: Filenames may not contain 0x00, ":" or "/". Seems ok.

Windows is a little stricter: Filenames may not contain 0x00-0x1f, may not end with space, may not end with ".", cannot contain either of
the chars <>:"/|\=*

But, it seems Vice (at least v3.1 on OSX) filter the filenames as well, it only permits chars a-zA-Z0-9!#%$@&()=+-;<>_^*'?

So, the least common denominator is !a-zA-Z0-9#%$@&()=+-;_^'

I decided to encode 4 bits in every char. Decoder takes 28 bytes:
org $0801
.word $0809,$d000
.byte $9e,"2061",0,0,0
decmore:
lda ($bb),y
asl
asl
asl
asl
iny
eor ($bb),y
sta dest,x
inx
iny
bne decmore
dest:

And encoding is done with a small Python script:

from shutil import copyfile
fn = open("into_filename.prg",'r+b')
fileprg = fn.read()
fn.close()

odds = "pabcdefghijklmno"
name = ""

for byt in fileprg:
oddchar = odds[byt & 0x0f]
byt2 = byt ^ (ord(oddchar) - 0x20)
evenchar = odds[byt2 >> 4]
name = name + evenchar
name = name + oddchar

print ("name length=%d" % len(name))
name = name + ".prg"
print ("name=%s" % name)
copyfile("mahoneyfont2.prg", name)


The program encoded in the filename is:
; A rom-based font in < 128 bytes by Pex Mahoney Tufvesson,
; created for the CSDb 128b font compo initiated by lft.

org $081d
sei
lda #$19
sta $D018
lsr $01
copymore:
lda ($39),y ;current basic line number
rla ($39),y ;current basic line number
sta ($fe),y
iny
bne copymore
inc $ff
inc $3a
bne copymore
rol $01
rts

which results in the filename: chnieilmehhppfdaoagigcgimaknhhhpkgjfkojfgjhpkaffdacp.prg

...making a custom font in 28+2 bytes!

Anyway, it happened to work with my setup: MacOS, x64sc and vice v3.1

Putting the program on a d64 wouldn't work, since filenames on disk are limited to 16 chars.
Putting the program into a .t64 file wouldn't work, since filenames in that file format are limited to 16 bytes.
However, filenames on Datasette (.tap-files are the closes we'll come in emulator-land) can use 187 chars, so as a tape loaded font creation, it would be ok!


Peace, love and font creation! / Pex
---
Have a noise night!
http://mahoney.c64.org
2018-04-01 13:17
Rastah Bar

Registered: Oct 2012
Posts: 336
Thanks for the explanation. Very interesting!
2018-04-01 13:35
Mixer

Registered: Apr 2008
Posts: 422
Pex taking it to level 2 again :), but... now i can't count the bytes, they're meaningless! :(
2018-04-01 13:39
tlr

Registered: Sep 2003
Posts: 1714
Worst abuse of rules. Brilliant! ;)
2018-04-01 17:21
Rastah Bar

Registered: Oct 2012
Posts: 336
On a real C64, which characters are not allowed in a filename?
The code below copymore: without the ROL $01 is 16 bytes ...
2018-04-01 17:28
Pex Mahoney Tufvesson

Registered: Sep 2003
Posts: 50
On a d64, filenames are padded with an $a0, so I guess that's illegal.
And a .t64 file (which indeed has _nothing_ to do with a real Datasette), filenames are padded with $20.
Apart from that, I guess it will be fine. So, no JSR $xxxx or LDY #$xx
:)
---
Have a noise night!
http://mahoney.c64.org
2018-04-09 10:31
Copyfault

Registered: Dec 2001
Posts: 466
First of all: f**cking ace decompression algo, Mahoney! As you said several times, it's the fun part of madness. Can it adequately be put into words what this c64 drives us to ;) ? Guess never ever!

I gave this approach a go but wanted to stick to real hw with a 1541 disc drive. Ended up quite Font-o-holic [31 bytes].

That jmp($00bb) was utilised amongst other things. Do not exactly know which characters are not allowed, but it really made the task even more difficult. A pity lft did not bend the rules to allow at least this case. But ofcourse I can live with it ;)
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Steffan/BOOM!
Mike
stephan-a
Guests online: 79
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Jeroen Tel  (9.7)
3 Stinsen  (9.6)
4 Mutetus  (9.6)
5 Linus  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.059 sec.