KeenQuill

Tools, assembly, and file formats.
thehackercat
Posts: 69
Joined: Sat Sep 26, 2009 10:49 pm
Location: Mississippi, USA

KeenQuill

Post by thehackercat »

Hey guys! I'm working on a utility called KeenQuill, which will let the user edit the STORYTXT.CKxx files in a user-friendly way.

What I need it to do is display the ASCII file as Keenxx.exe would.
Then, the user could edit the text file and KeenQuill would refresh the window every time the user pressed a key.
Could anyone give me some help with this? I'm writing it in Python, because QBASIC just isn't working for me.

Unless someone could help me on the QBASIC front..

SO, to recap, I need the code that Keen:Vorticons uses to parse the STORYTXT.CKxx files.
Dr. Kylstein
Posts: 120
Joined: Wed Dec 16, 2009 5:20 pm

Post by Dr. Kylstein »

The character values correspond directly to rows and columns in xFON0000.bmp. For example, the bullet point 0x09 is row 0, column 9 in the bitmap. The black on white characters correspond with standard ASCII and the red on gray ones are ASCII+0x80. The status screen patch works the same way but with the two halves swapped so that the pizza is at 0x00 and the black square is 0x80.

The special case for STORYTXT is that '~' appears to add 0x80 all characters between it and the line break. Also character 0x1F/0x9F seems to get replaced with a space for no apparent reason.
thehackercat
Posts: 69
Joined: Sat Sep 26, 2009 10:49 pm
Location: Mississippi, USA

Post by thehackercat »

OK... is there any way I could use xxFON0000.BMP as a font? Maybe convert it with Truetype and have it packaged along with the .zip?
Kdash
Posts: 405
Joined: Sat Feb 26, 2005 5:45 pm

Post by Kdash »

Making a font wouldn't be ideal, because a lot of modders change it (or just the pictures, at least).

I'd ask Levellass or Lemm or someone about the file compression or format or whatever, and how to convert that into an image on the screen.
Dr. Kylstein
Posts: 120
Joined: Wed Dec 16, 2009 5:20 pm

Post by Dr. Kylstein »

You need a graphics library. Rendering the font the way Keen does it is trivial for any decent graphics system. I know for a fact SDL can do it, and bindings for Python are available. Trying to do this in a text-mode app isn't going to be much better than a standard text-editor.

Edit: Are you using text-mode? or are you using a GUI toolkit? Most GUI toolkits support custom drawing routines which should be just as good as SDL for this.
thehackercat
Posts: 69
Joined: Sat Sep 26, 2009 10:49 pm
Location: Mississippi, USA

Post by thehackercat »

Well, my Python setup includes Wxpython, with which I am not very familiar. Could you give me some bindings for that? Tkinter is OK too.
EDIT: Here's what I have so far:

Code: Select all

import wx
from wx.lib.wordwrap import wordwrap

class MyApp(wx.App):
   def __init__(self, redirect=False, filename=None):
       wx.App.__init__(self, redirect, filename)
       self.frame = wx.Frame(None, wx.ID_ANY, title='KeenQuill BETA')

       self.panel = wx.Panel(self.frame, wx.ID_ANY)

       # copy the code for the AboutBox

       # change the button's parent to refer to my panel
       b = wx.Button(self.panel, -1, "About KeenQuill", (0,10))
       self.Bind(wx.EVT_BUTTON, self.OnButton, b)

       self.frame.Show()

   def OnButton(self, evt):
       # First we create and fill the info object
       info = wx.AboutDialogInfo()
       info.Name = "KeenQuill"
       info.Version = "BETA"
       info.Copyright = "(C) 2009 Raymond Patrick"
       info.Description = wordwrap(
           "KeenQuill is a utility that modifies the story text in Keen:Vorticons."
           "Eventually it will be expanded to modify the Help and Previews screens"
           "as well. Please note, this beta is not a stable release, and I am not "
           "liable for any damage that this program may cause to your computer.   ",
           # change the wx.ClientDC to use self.panel instead of self
           350, wx.ClientDC(self.panel))
       info.WebSite = ("http://keenmodding.org", "The Keen:Modding site")
       info.Developers = [ "Ray Patrick (thehackercat)",
                           "The folks at K:M",
                           "The folks at the PCKF" ]

       # change the wx.ClientDC to use self.panel instead of self
       info.License = wordwrap(licenseText, 500, wx.ClientDC(self.panel))

       # Then we call wx.AboutBox giving it that info object
       wx.AboutBox(info)

overview = """<html><body>
<h2><center>wx.AboutBox</center></h2>

This function shows the native standard about dialog containing the
information specified in info. If the current platform has a native
about dialog which is capable of showing all the fields in info, the
native dialog is used, otherwise the function falls back to the
generic wxWidgets version of the dialog.

</body></html>
"""


licenseText = "This program can be freely distributed. Do not distribute this program commercially and be sure to give me credit if you make changes to the source code."

if __name__ == '__main__':
   app = MyApp()
   app.MainLoop()
thehackercat
Posts: 69
Joined: Sat Sep 26, 2009 10:49 pm
Location: Mississippi, USA

Post by thehackercat »

OH, could someone more fluent in wxpython than me help me implement a text window into that frame?
lemm
Posts: 554
Joined: Sun Jul 05, 2009 12:32 pm

Post by lemm »

Hope this is going well. I am making a patch to allow 1 hint text per level in Keen1 using a storytxt type file.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

*Slaps self*

Why so am I!

I shall abandon it immediately!
thehackercat
Posts: 69
Joined: Sat Sep 26, 2009 10:49 pm
Location: Mississippi, USA

Post by thehackercat »

BUMP.

Sigh.. Time to learn SDL. Anybody got a tutorial they know of out there? Maybe someone could help me out on IRC as well.
Draik
Posts: 117
Joined: Sat Jul 26, 2008 8:52 am
Contact:

Post by Draik »

SDL? What language are you using?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Surely VB or Java would be more appropriate?
Draik
Posts: 117
Joined: Sat Jul 26, 2008 8:52 am
Contact:

Post by Draik »

Wait, now that I think about it, you were using Python earlier, so you're probably using SDL through Pygame. Don't have a clue there, sorry. Not a big fan of Python, I must say.
gerstrong
Posts: 63
Joined: Sun Jan 25, 2009 3:21 pm

Post by gerstrong »

If you want to use SDL you might be using C/C++. There are ports for other languages, but I doubt, that they are as solid. The documentation of SDL is not even the best. I learned a lot of things by trail and error.

A good tutorial is here:

http://lazyfoo.net/SDL_tutorials/index.php
xtraverse
Patch Crafter
Posts: 290
Joined: Tue Sep 02, 2003 6:42 pm
Location: Easter Island
Contact:

Post by xtraverse »

Python would be fine for this project.

TKinter has a Canvas widget that can display all kinds of graphical stuff. The Python Imaging Library (PIL) should allow you to import the xxFON0000 image and draw regions of it onto another image, which you can display in the canvas.
Post Reply