40 column routines (split from: Two Days to the Race)

Basic and Machine Language

Moderator: Moderators

DarwinNE
Vic 20 Devotee
Posts: 231
Joined: Tue Sep 04, 2018 2:40 am
Website: http://davbucci.chez-alice.fr
Location: Grenoble - France

Re: 40 column routines (split from: Two Days to the Race)

Post by DarwinNE »

Hi Mike,
many thanks for the useful hints!
Mike wrote: ... pulling this off just 3 days after the "Hello World" of the Italian language (so to speak ) is quite an achievement.
The C code of the game is generated with a tool I wrote, called AWS2C:

https://github.com/DarwinNE/aws2c

Everything is done to have very simple I/O entry points and to be as portable as possible: it's not very difficult to hook specific routines.
Mike wrote: You seriously should reconsider the arrangement of the characters in the text screen though. As I've spotted in your alpha, you use a row-wise arrangement
I see you noticed it :D

To say the truth, I was looking at your code and I haven't understood the scrolling routine, so nice and tidy, for a few days :oops:
I realized yesterday it would have been much easier to arrange the screen with a column-wise organization.
Currently, as you saw, the scrolling mechanism is a /real/ mess :oops: :oops: :oops:

It's one of the reasons why I haven't shown the code, yet :oops:

There're two ideas that I found non trivial. The first one is to set the chargen and the video memory both at $1000, then fill the video memory with characters that make the chargen read only starting from $1100. The second is that it is much better to have the screen oriented in a column-wise arrangement.
User avatar
Mike
Herr VC
Posts: 4846
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: 40 column routines (split from: Two Days to the Race)

Post by Mike »

DarwinNE wrote:There're two ideas that I found non trivial. The first one is to set the chargen and the video memory both at $1000, then fill the video memory with characters that make the chargen read only starting from $1100. The second is that it is much better to have the screen oriented in a column-wise arrangement.
Add to this the duplicated nibbles in the font definition, so it's not necessary to shift left 4 times to get the upper nibble (just mask out the correct half), and you're nearly there. :wink:
in another thread, DarwinNE wrote:BTW someone tried to play the game?
I'll try to take the time for this on this weekend.

From a quick start up I've however already found out, that you'll also need to handle NTSC correctly. Currently, on NTSC the display window is shown off center - something which is (besides the column-wise char arrangement) also correctly handled by my "On"-routine by putting the correct values into the horizontal/vertical position registers of the VIC chip, which *are* different for PAL/NTSC:
Mike wrote:This also takes care, that PAL and NTSC VIC chips need different values for some registers. The values are obtained by adding/subtracting offsets from the default values of the VIC registers in the KERNAL ROM at $EDE4, so the screen remains centered on both TV systems.
Cheers,

Michael
DarwinNE
Vic 20 Devotee
Posts: 231
Joined: Tue Sep 04, 2018 2:40 am
Website: http://davbucci.chez-alice.fr
Location: Grenoble - France

Re: 40 column routines (split from: Two Days to the Race)

Post by DarwinNE »

Mike wrote: Add to this the duplicated nibbles in the font definition, so it's not necessary to shift left 4 times to get the upper nibble (just mask out the correct half), and you're nearly there. :wink:
Thanks for the hint! I noticed that the nybbles were repeated but I must've forgot it, I will review the code for finding other inefficiencies.
Mike wrote: From a quick start up I've however already found out, that you'll also need to handle NTSC correctly. Currently, on NTSC the display window is shown off center - something which is (besides the column-wise char arrangement) also correctly handled by my "On"-routine by putting the correct values into the horizontal/vertical position registers of the VIC chip, which *are* different for PAL/NTSC:
That's true. I will correct this soon.
DarwinNE
Vic 20 Devotee
Posts: 231
Joined: Tue Sep 04, 2018 2:40 am
Website: http://davbucci.chez-alice.fr
Location: Grenoble - France

Re: 40 column routines (split from: Two Days to the Race)

Post by DarwinNE »

Hi, Mile

Even if it is far from being presentable, if you want to have a look at the 40 column driver, here is the file on which I'm working on:

https://github.com/DarwinNE/aws2c/blob/ ... vic40col.s

And here's the corresponding C header:

https://github.com/DarwinNE/aws2c/blob/ ... vic40col.h

This way, you will not have to disassemble the code to see its horrors :)

Those files are part of aws2c, the project on which I am working since a few months ago and that allows to generate C code for text adventure games.
I only need there a pretty simplistic driver. Once I get something stable, I'm planning to create a separate GitHub project specifically dedicated to the 40 column driver, as it seems that there's enough interest.

Sorry for the current state of the scroll routine and I haven't reviewed the code throughly yet. Of course, I'm open to suggestions, they're always welcome.

The code includes the corrected initialization routine you suggested, but I haven't reviewed yet the _putc40ch routine.
DarwinNE
Vic 20 Devotee
Posts: 231
Joined: Tue Sep 04, 2018 2:40 am
Website: http://davbucci.chez-alice.fr
Location: Grenoble - France

Re: 40 column routines (split from: Two Days to the Race)

Post by DarwinNE »

Hi to all,
I put together a small example here:

https://github.com/DarwinNE/aws2c/tree/ ... t_VIC_40ch

It's not very difficult to use the 40-column console driver. The example file is as follows:

Code: Select all

#include "vic40col.h"

#define BUFSIZE 38

int main(void)
{
    char buffer[BUFSIZE];
    initGraphic();
    negative();
    puts40ch("Please enter your name: \n");
    positive();
    puts40ch("> ");
    gets40ch(buffer, BUFSIZE-1);
    puts40ch("Hello ");
    puts40ch(buffer);
    puts40ch("\n\n");
    cgetc40ch();
    normalText();
    return 0;
}
The actual driver is in vic40col.s. Feel free to use it and modify it as you want.
I put more information about how to compile and run it in the directory on GitHub.
The colour is fixed at compile time in vic40col.s.
I haven't written routines to change the cursor position from C, but in the asm file you can do it by changing currLine and currCol and then calling _puts40ch.
Post Reply