GDR Forum Index
Podcast Podcast
Dev Dev Logs
Search Search
RSS RSS
Register Register
Log in Log in
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - PETSCII paint
View previous topic :: View next topic  
Author Message
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Tue Sep 06, 2011 2:56 am    Post subject: Development Log - PETSCII paint Reply with quote

what happened so far:
latest release
making of, timelapse part 1 of n (n > 1)

in the off-topic thread, Dennis wrote:
Maybe I should start a devlog for PETSCII paint after all. I'm currently on version 0.4 (fixed two of the three issues (backspace key in filename entry works now and existing files can now be overwritten)). I've reached a point where continuing to develop the BASIC version is getting quite tiresome and execution speed is slooooow.

Also, I would like to allow having an individual background color/character color per 8x8 block but for that I will have to rewrite it to use the C64 bitmap mode. In that mode however, PRINTing or POKEing characters to the screen isn't as easy as putting the character code to a certain address and instead the 8 bytes forming a character must be copied from the character ROM data to the respective bytes forming the bit pattern on the screen.

I have already written a small test program in BASIC which does just that but it's very slow and clearing all bytes of the full screen bitmap takes way too many seconds if not even more than a minute. So, it's time to learn C64 assembler or to abandon the project.

In that last sentence up there I was facing two options of which I did chose neither one in the end, because I found something really nice on the web: cc65 (it's a C compiler with an almost feature complete ANSI C implementation which can target the 6502 microprocessor (and derivatives such as the one running in the C64).

So I will rewrite PETSCII paint in C to get to v.0.5 (which will support individual background/foreground color for each character and I think I'll even get rid of the inverse characters from each of the two charsets (which can then be emulated by switching background/foreground color) and copy the unique character patterns of each of the two charsets to form a custom third one which will include all characters from both sets available at the same time in a single "painting".
_________________
0xDB
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Tue Sep 06, 2011 9:01 am    Post subject: Reply with quote

Before I forget: The goal of this is to write a tool for the C64 which can be used to create character based art (like ASCII art, except in colors and using the PETSCII characters).

making of (rewrite for 0.5) part a

Summary for today:
Started the rewrite in C. So far it's just init/shutdown code, clearing the screen, grabbing all unique characters from the charset generator ROM (and adding a custom character (the smiley face from ASCII)) into an internal buffer and displaying those copied characters (for debugging).

Took me quite some time to find that the address at which the VIC-II expects the color bits can not be altered and is always at 1024(dec) in bitmap mode. The only thing that can be changed is the start address at which it expects the bit patterns for the screen.

Technical details:
In standard bitmap mode, the VIC-II chip uses two memory addresses. At one of those addresses (which is always the same) it interprets each byte as color information for each 8x8 pixel block at the screen. Four of those bits of each byte are interpreted as the foreground color and the other four bits are for the background color. At the other of the two addresses it reads 8 bytes for each of the 40*25 screen positions and interprets the bits in those bytes as pixel set/pixel not set, using the color information byte from the respective other address to determine the color for each set/unset pixel. So a full screen bitmap in that mode requires 1000 bytes for color information plus another 8000 bytes for the pixel information. I will require only 2000 (plus a few for extra info) bytes to store a full screen PETSCII paint file, because I will not store the whole bit pattern but just the character code and the color info byte for each 8x8 block.
_________________
0xDB
View user's profile Send private message Visit poster's website
n29
Developer

Joined: 13 Sep 2005
Posts: 879

PostPosted: Tue Sep 06, 2011 4:04 pm    Post subject: Reply with quote

Dennis wrote:

Started the rewrite in C. So far it's just init/shutdown code, clearing the screen, grabbing all unique characters from the charset generator ROM (and adding a custom character (the smiley face from ASCII)) into an internal buffer and displaying those copied characters (for debugging).


AAaaaaahhhhhh! That particular set of neurons haven't fired since 1986!!!! Ouch!
_________________
My Blog
View user's profile Send private message
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Wed Sep 07, 2011 8:04 am    Post subject: Reply with quote

Today I lost a couple of hours squashing a nasty bug(links to the whole embarrassing timelapse recording of that).

I was allocating some more RAM prior to clearing the screen and displaying the character test when suddenly garbage started showing up on the screen.
As I removed the RAM allocation again, things were back to normal.

So I wrote a test routine which would allocate the RAM and display the addresses at which they were allocated and I found that the last allocation started at an address which was beyond the screen start address seen by the VIC-II, so it would display the bit patterns I wrote into that last buffer there. Lesson learned: the cc65 compiler allocates RAM where it wants and does not check whether it's inside the address range currently selected for the VIC-II

So, to work around that problem I decided to switch the video bank (that's just a fancy expression for the 16 KiB chunk of the C64s 64KiB RAM which is "seen" by the VIC-II), so that the RAM interpreted as bit patterns would be far behind my allocated RAM.
In theory that should have worked in under 5 minutes but instead I spent hours trying to figure out how to correctly switch that video bank and to find the correct new screen start position fucking around with a certain single bit of which I didn't really know how it affected the offset of the screen start from the base address of the bank (for some reason I even thought there were more of those bits to control that). At some point I even lost my head and poked in random bits to test if that would even affect anything at all... nothing.

I blame that to bad documentation in the reference manual. The aforementioned bit is pulled into a register in the VIC-II chip as the 10th bit next to a 9 bit videomatrixcounter address, so I assumed it would offset the screenstart by 512 bytes... only it does not, it offsets it by 8192 bytes.
Also, I realized after some time that the color information bytes are also pulled from a different address after the bank is switched. Now actually after reading the documentation again, I realized the videomatrixcounter address is 10bits wide and there is another 3 bit address to the right of it in the same register so that other bit is being pulled in as 2^13 = 8192 so that makes perfect sense and I should rather blame my reading skills instead of blaming the docs.

In short: It does not do anything visibly more yet than it already did yesterday but under the hood it now uses a different RAM area for the screen so my own buffers and the display don't interfere anymore.
_________________
0xDB
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Thu Sep 08, 2011 8:57 am    Post subject: Reply with quote

todays timelapse making of: the cursor

And now I have a neat little "walking ants style border" cursor up and running. In the BASIC version the cursor was just a character which quickly replaced itself with the underlying character of the painting and back again.
In this version I implemented the cursor using an animated hardware sprite which is always shown on top of the painting.
The neat thing about that is that I get the cursor display for free without having to change the painting at all.
_________________
0xDB
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Fri Sep 09, 2011 8:25 am    Post subject: Reply with quote

todays timelapse making of: status bar, brushes, color selection and fancy brush selection mode

I now have a neat little status bar at the top which unlike in the BASIC version will always show all 8 brushes and their current colors at the same time. The selected brush number is highlighted.

Colors for each brush can be cycled through for the currently selected brush and I implemented a fancy brush selection mode which allows using the cursor to select a character from the full charset.

This new brush selection mode is far superior to the one in the BASIC version where brushes could only be cycled around but without ever seeing the full set available at the same time.
Also, cycling colors is also working in brush selection mode so each character is displayed with the brush colors.

screens:

_________________
0xDB
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Sat Sep 10, 2011 7:36 am    Post subject: Reply with quote

todays timelapse making of: canvas and brush operations

Today I implemented all the canvas and brush operations (that's placing color,character,both from brush to canvas and grabbing color,character,both from canvas into selected brush), so now it's possible to create some PETSCII art with the tool.

I still need to write saving/loading routines, a routine for getting the filename from user input and a printlike routine to translate ANSI C strings into my custom charset and to display those on the screen. After that is done, the rewrite from 0.4 (BASIC) to 0.5 (C) will be complete and it will have all (plus the new foreground/background color per char) features the previous version had.
_________________
0xDB
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Sun Sep 11, 2011 8:05 am    Post subject: Reply with quote

todays timelapse making of: optimization, filename dialog, saving/loading and help-screen (had to split that to get under youtube timelimits)
part 1 of 2
part 2 of 2

This wraps up the rewrite and I'm on version 0.5, making a new release. I have no idea what to do next with it, except maybe using it to create some art.
release page / direct link to 0.5 download

sophisticated developer notes

screen:

_________________
0xDB
View user's profile Send private message Visit poster's website
PoV
Moderator

Joined: 21 Aug 2005
Posts: 10859
Location: Canadia
PostPosted: Sun Sep 11, 2011 9:35 am    Post subject: Reply with quote

Very cool man. I always wanted to toy around with cc65, to see what I could get going.

Have you tested on actual hardware yet, or just emu's?
_________________
Mike Kasprzak
'eh whatever. I used to make AAA and Indie games | Ludum Dare | Blog | Tweetar
View user's profile Send private message
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Sun Sep 11, 2011 11:58 am    Post subject: Reply with quote

My C64 is dusting around at my parents house so just emulators. Also I don't know if my cable for transferring from PC to C64 still works. There was some software called Star Commander which could do that easily using a C64 floppy connected to the PC with a custom built cable (building instruction can be found on the web).
_________________
0xDB
View user's profile Send private message Visit poster's website
PoV
Moderator

Joined: 21 Aug 2005
Posts: 10859
Location: Canadia
PostPosted: Sun Sep 11, 2011 12:37 pm    Post subject: Reply with quote

Yeah, I ordered a little dongle on eBay that connects a C64 floppy drive to a PC too, but I can't remember how to use it.

Also, I think it's time to visit your folks. :D

I still want one of these: http://www.1541ultimate.net/content/index.php
_________________
Mike Kasprzak
'eh whatever. I used to make AAA and Indie games | Ludum Dare | Blog | Tweetar
View user's profile Send private message
n29
Developer

Joined: 13 Sep 2005
Posts: 879

PostPosted: Sun Sep 11, 2011 3:00 pm    Post subject: Reply with quote

Very cool. You should definitely put this on your cv, maybe even put it on google code.
_________________
My Blog
View user's profile Send private message
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Mon Sep 12, 2011 8:29 am    Post subject: Reply with quote

I am mentioning my website in my CV so it's automatically on there. I'm glad you guys like this thing. :)
I will try to run it on the real hardware probably next weekend. That cartridge looks like a cool thing to have!

Meanwhile I've created some DF fan art with it:

_________________
0xDB
View user's profile Send private message Visit poster's website
PoV
Moderator

Joined: 21 Aug 2005
Posts: 10859
Location: Canadia
PostPosted: Mon Sep 12, 2011 9:13 am    Post subject: Reply with quote

I can't remember. Is the smiley part of the usual petscii set?
_________________
Mike Kasprzak
'eh whatever. I used to make AAA and Indie games | Ludum Dare | Blog | Tweetar
View user's profile Send private message
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Mon Sep 12, 2011 9:31 am    Post subject: Reply with quote

Heh, no, I stole that from ASCII.
_________________
0xDB
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Sat Sep 17, 2011 5:25 am    Post subject: Reply with quote

Dennis wrote:
I will try to run it on the real hardware probably next weekend.
Oh well my XE1541 (or XM1541) cable does not seem to work anymore or I could not get Star Commander to work with it on this machine (not even when I booted in pure DOS mode) so I currently have no way to transfer the file to a real C64 disk and thus I can't try it on the real thing for the time being. I'd also have to put the soundchip back into my C64 before using it as that one is still mounted to the Catweasel MKIII card which is dusting around somewhere else (sigh, all that hacky stuff which was interesting a few years ago is now all unusable and b0rked).

append:
Finally got the drive(1541-II) working in DOS and after playing around with the parallel port mode settings in the BIOS, so that Star Commander could access it. Then I spent 2 hours trying to find a floppy disk which wasn't broken. They all looked fine physically but I kept getting timeouts and read errors and so I still failed to transfer PETSCII paint for use on the real machine. Bummer.
_________________
0xDB
View user's profile Send private message Visit poster's website
Sirocco
Moderator

Joined: 19 Aug 2005
Posts: 9441
Location: Not Finland
PostPosted: Sat Sep 17, 2011 9:42 am    Post subject: Reply with quote

I've got a bunch of old commie 5.25" disks in one of my closets. I wonder how many of them are still readable? I haven't given any of them a spin in about ten years.
View user's profile Send private message Visit poster's website
0xDB
Developer

Joined: 26 Dec 2005
Posts: 1655
Location: Your consciousness.
PostPosted: Mon Sep 19, 2011 2:55 am    Post subject: Reply with quote

Mine still worked a few years ago. It's a little sad they're starting to fail now. Maybe it's still just the cable or some timing problem though and I should try them on the C64 to see if they're really broken.
_________________
0xDB
View user's profile Send private message Visit poster's website
n29
Developer

Joined: 13 Sep 2005
Posts: 879

PostPosted: Wed Sep 28, 2011 4:03 am    Post subject: Reply with quote

I have the GEOS disk around somewhere, most of my old disk didn't turn in the sleeve at all. Yep, magnetic media is not durable over decades. I wonder if cassette tapes do better?
_________________
My Blog
View user's profile Send private message
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - PETSCII paint

Use this link to get a Sign-On Bonus when you get started!

All trademarks and copyrights on this page are owned by their respective owners. All comments owned by their respective posters.
phpBB code © 2001, 2005 phpBB Group. Other message board code © Kevin Reems.