Kernel Routines and Arbitary Screen Size

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Kernel Routines and Arbitary Screen Size

Post by hawk »

I've been attempting to get some code working using CC65 and I've run into the problem where the VIC-20 kernel doesn't handle the actual screen size, but only the default screen size. I've done a bit of searching and have been unable to find much discussion of this, but I'm guessing that I'm not the first person to tackle this problem. I guess it seems obvious that Commodore did it that way for memory (or maybe performance) reasons, but for a machine with a re-sizable display it's a pain in the a$%#.

Has anybody attempted to unravel what is required to get the kernel functions to work with an arbitrary sized screen?

Is it possible to replace just some of the screen routines, and the rest will function correctly?

Or do you have to replace so much code that it blows out the program size?

Most of the stuff I work with is targeted at expanded systems anyway.
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Post by nippur72 »

My only experience with kernel routines and non-standard screen sizes is with PRNSTR ($cb1e) and PRNINT ($ddcd).

I use this workaround: I place the cursor pointer ($d1) at the right screen location and call PRNSTR or PRNINT normally. Then I call GOHOME ($e581). In machine code:

Code: Select all

my_print:
     jsr PRNSTR
     jsr GOHOME
     rts
Works ok for games when you need just some printing (eg. "GAME OVER").
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Kernel Routines and Arbitary Screen Size

Post by Mike »

hawk wrote:[...] what is required to get the kernel functions to work with an arbitrary sized screen?
The number of columns (and, for that matter, also the number of rows) are hardcoded within the screen editor all over the place.
Is it possible to replace just some of the screen routines, and the rest will function correctly? Or do you have to replace so much code that it blows out the program size?
You can't replace only parts of the screen editor - there are no vectored calls inside. You'll need to replace the entire code, 1.5 K worth. And hook the replacement into the vectors of BASIN, and BSOUT, like all the 40 column emulators also do.
I've been attempting to get some code working using CC65 and [...]
That's the good thing of C. You're always free to write your own versions of printf(), and scanf(). ;)

TNT has coded a screen print routine which doesn't use the kernal, and allows for custom screen sizes. It's here.

Michael
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Thanks for the info guys...that's exactly what I'm after. 8)
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

Anyway I believe cc65 also comes with its own screen routines, or at least the conio library used by e.g. Contiki. However even that one was hard coded for 22 columns when I was playing with it a number of years ago.
Anders Carlsson

Image Image Image Image Image
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Yeh, the cc65 conio library just links into the kernal routines. Good for keeping the code size smaller, but doesn't solve the variable screen size issue. It does, however, use the vector address, so I may only need to replace the kernal routines.

My first thought was to just duplicate the kernal routines, replacing the hard coded bits (including the screen line table), but it looks like TNT has come up with a better alternative. I just need to get it to assemble using ca65.
Post Reply