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 > C64 Coding > ascii to petscii quick and dirty
2010-08-15 14:24
Angel of Death

Registered: Apr 2008
Posts: 211
ascii to petscii quick and dirty

Was looking for a nifty little program to convert an ascii text into petscii and save me an hour or so of retyping a text.
Couldn't get petcat to do what i wanted and furthermore ran into this : ASCII <--> PETSCII Converter for Windows.
After a nice LOL I decided to cook up some quick'n dirty routine myself.

* = $1000

start
lda #$0e
jsr $e536
lda #14
jsr $ffd2

ldx #$00
-
lda text,x
jsr convert
sta $0400,x
inx
cpx #(ndtext-text)
bne -
loop
inc $07e7
jmp loop

convert
sta temp
lda #%00100000
bit temp
bvc nobit6
beq nobit5
lda temp
and #%10011111
rts
nobit5
nobit6
lda temp
rts

temp
.byte $00

text
.text "This is a test text."
ndtext

Also not much to look at but by running the text through this an hour of re-typing became 5 minutes of editing.
Do your worst with it...
2010-08-15 14:39
chatGPZ

Registered: Dec 2001
Posts: 11386
and petcat wouldnt do it ... how?
2010-08-15 14:56
Angel of Death

Registered: Apr 2008
Posts: 211
Probably didn't do it right.
used command line : petcat -text -o text.prg -- text.txt (and without the -text arg)
it worked so far that it converted the file, got the CR's and the LF's right but mixed up the letters with capitals.
And just what I said. I couldn't get it to do what I wanted. Stopped trying when I got a spark of brightness how to do it in MC.
But if you can tell me what I did wrong then using petcat will be even quicker. (lazy bastard that is me :)
2010-08-15 15:11
chatGPZ

Registered: Dec 2001
Posts: 11386
$ echo "abcABC" > test.txt
$ petcat -text -o text.prg -- test.txt
$ hex text.prg
0000  41 42 43 61 62 63 0a                              ABCabc.
$ hex test.txt
0000  61 62 63 41 42 43 0a                              abcABC.


works exactly like it should? *shrug*
2010-08-15 15:21
Angel of Death

Registered: Apr 2008
Posts: 211
That was indeed the result I got. But I was looking for:
0000 01 02 03 41 42 43 abcABC
And now I know where I took the wrong turn.
I wasn't looking for Petscii but for screencodes I could 'poke' directly into screenmem. That is something completely different. (duh)
Thanks for clearing that up!
(hmmm maybe an idea for another tool)
2010-08-15 15:24
chatGPZ

Registered: Dec 2001
Posts: 11386
:) indeed. it would also be something petcat could/should support. but considering how extremely ugly the petcat code is..... someone else can look at it =P
2010-08-15 15:29
WVL

Registered: Mar 2002
Posts: 902
btw, since it seems that you're using 64tass, you can also do it this way :
.enc screen         ;set text encoding to screencodes 
 .text "blablabla"  ;<- just your text
.enc none           ;back to normal encoding scheme

I hope you don't get a FFFFUUUUU-moment now :) Nowadays the first line of code in almost all of my sourcecodes is .enc screen ;)
2010-08-15 15:46
Angel of Death

Registered: Apr 2008
Posts: 211
@WVL I know that but I wanted to feed it into a c64 native wordprocessor I always use. (and coded)
If it was just to include in a piece of code I would have used the .enc pseudo-op.
@groepaz *nods* then don't touch it! :)
btw. Thanks everyone for the fast reply...
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
deetsay
zscs
Weetibix
Courage
iAN CooG/HVSC
ciccior2003/HF
ArturoDente
ΛΛdZ
Guests online: 102
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

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