WIP VIC32 - 32-column 'pet loader' style program

Basic and Machine Language

Moderator: Moderators

User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

WIP VIC32 - 32-column 'pet loader' style program

Post by Victragic »

Hi all,

there are many programs out there that allow the Vic to display 40 columns by 24/25 rows of text, allowing varying degrees of compatibility with the screens of other Commodore computers. While the 22 column screen of the Vic is not great for text, 40 columns can also be a little difficult to make out due to the lack of resolution possible in a 3x7 character matrix.

I feel that 32 column text is not a bad compromise, having seen this successfully implemented in recent text games such as Cometfall by Kweepa, and others. For me, a 32 column x 16 row text display is the same format as one of my other machines, a lowly Dick Smith (Laser) VZ200.

I thought I'd combine my (somewhat wasted!) earlier efforts at allowing 'native' screen modes other than 22x23, with a project to allow 32 x 16 text. I toyed with the idea of a 32x20 display, but in the end decided that for readability purposes, 32 x 16 was a nicer prospect.

Requirements:
* NTSC or PAL VIC
* 8K RAM at A000
* At least some RAM above $2000 for programs

Features and limitations:
* lowercase character set only
* 6x10 character matrices with 'true' descenders
* Runstop/Restore retains screen format
* only 1 character colour on screen allowed - can be changed by changing current text colour
* can 'poke' to and 'peek' screen values, screen memory starts at $be00 (48640)
* basic limited to 2-line entry

There are 2 versions of VIC32 on the disk image. [As of 14 February]
* VIC32 A000 - this loads in directly to $A000. Could be loaded by another program, and evoked by SYS 40963
* VIC32 BASIC - this loads in as a BASIC program. On running, the program attempts to relocate to A000 and will perform a 'cold' start

Entry points:
----------------
SYS40960 - performs a cold-ish ('luke-warm') start. Will reset everything and display the startup screen, and throw the user to BASIC. Bottom of memory is shifted to $2001. Any existing BASIC program will be lost.
SYS40963 - performs a warm start. If you enter here from outside VIC32, it will implement 32 column display and simply return. Note bottom of memory is NOT shifted, only the minimum memory locations required to implement the program are affected. If called from within VIC32, BASIC program listing should be retained.

Changing Polling Frequency
---------------------------------
I've used a 'polling' method to update the screen rather than rewriting the character output routines. This was my personal preference to allow screen locations to be accessed directly in a fairly simple manner. It does means that when the screen is refreshed or scrolls, the machine will slow down considerably. You can change the rate at which the screen is polled by changing the value of $ef (239) - it is set to 1, changing this to 3, 7, 15, 31, 63, 127 or 255 may reduce the load but will also yield increasingly 'laggy' results.

Re-defining Character Sets
---------------------------------
I've tried to imitate the built-in character set of the Vic as much as I could, however if this is not to your taste, you can change the character set - the character 'ROM' data starts at $AC00 (EDITED: was $AD00) and comprises 256 *10-byte* characters. Note that only bits 0-5 are used in the definition, bits 6-7 must be zero.

For suggestions - feel free to suggest, but please don't be offended if I don't take them up. If you have a project that would somehow benefit from using this utility though, more than happy to help out.

UPDATE 7/3/21
-------------------
:Added some extras to the disk image:
: - Speedscript 3.2. Load it in after Vic32 is running. Note directory (CTRL-4) does not work, seems to be due to original code calling $DDCD directly to print output
: - A font editor. There's not much error parsing, so be careful when copying characters, etc.
: - A few fonts (ending .fnt). Load them using ',8,1' and they will load to the correct area. You may need to type 'new' afterward to restore memory pointers correctly. These fonts were all created using the font editor above.


UPDATE 21/2/21
--------------------
:Fixed problem with incorrect colour setting when performing screen clear


UPDATE 18/2/21
--------------------
:Fixed screen 'racing' issue that occurred when scrolling on PAL machines
:more elegant disable of commodore/shift, rather than 'brute force' method.

UPDATE 17/2/21
--------------------
:Improved scrolling performance - smoother and quicker
:Improved 'clear screen' performance

UPDATE 14/2/21
--------------------
:Much improved NMI-handler/BRK routine, restores screen completely
:Got rid of auot-chaining for IRQ vector - not particularly useful and would create as many problems as solves
:Can restart 'cold' while running - ie SYS 40960 (A000) no longer crashes the program
:Second entry point SYS 40963 (A003) added - effectively a warm-start. Can be called when VIC32 is running or from outside.
:Now two versions on the disk - BASIC loader version and A000-only image.
:Going with name VIC32 due to spectacular lack of imagination.. for now

UPDATE 13/2/21
--------------------
: Added BASIC stub, loads and runs as normal program into $1201 (no check to see if RAM at $a000 though)
: Performs 'luke-warm' start instead of cold-start. IRQ vector chains to existing address in $0314.
: Memory test skipped, only start of memory changed
: Various other pieces of redundant code removed/bypassed
: Screen link code table moved back to $d9.
: Rate of polling now set by $ef, not $df
: Values in vectors $F9 - $fd restored by IRQ routine. Routine therefore does not impact on zero page (other than $ef)

UPDATE 11/2/21
---------------------
: Significantly improved efficiency of routines.
: Added number of lookup tables to assist with speed
: Hopefully fixed scrolling issues?


Cheers
Attachments
vic32.zip
(24.7 KiB) Downloaded 65 times
Last edited by Victragic on Sat Mar 06, 2021 5:42 pm, edited 15 times in total.
3^4 is 81.0000001
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: 32-column 'pet loader' style program

Post by Noizer »

Very nice! Unfortunately it doesn't work with the $B000 version of vicmon.
Vicmon-2-b000.zip
(3.19 KiB) Downloaded 38 times
. SYS45056
Can you maybe adjust that?
Otherwise the source would be helpful here.
BR
Last edited by Noizer on Thu Feb 11, 2021 11:02 am, edited 1 time in total.
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: 32-column 'pet loader' style program

Post by Mike »

NICE!
Victragic wrote:I thought I'd combine my (somewhat wasted!) earlier efforts at allowing 'native' screen modes other than 22x23, with a project to allow 32 x 16 text. I toyed with the idea of a 32x20 display, but in the end decided that for readability purposes, 32 x 16 was a nicer prospect.
I tried the usual smoke-tests for a screen editor (typing in text, deletes, inserts, etc.) - what actually makes issues are scrolling PRINT outputs.

When I type in:

Code: Select all

1 PRINT"VIC-20";:GOTO1
RUN
... the screen does not fully scroll, rather the printed stuff 'remains' within a few rows as if in a window. When the program is stopped, the cursor afterwards moves around erratically. That's probably just an oversight somewhere.

Otherwise this is really a good tool to produce text adventures with BASIC programs, or the like.

Cheers,

Michael
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: 32-column 'pet loader' style program

Post by Mike »

Noizer wrote:Very nice! Unfortunately it doesn't work with the $B000 version of vicmon.Vicmon-2-b000.zip SYS45056. Can you maybe adjust that? Otherwise the source would be helpful here. BR
Victragic wrote:Requirements: [...] * 8K RAM at A000

Features and limitations: [...] can 'poke' to and 'peek' screen values, screen memory starts at $be00 (48640)
:roll: Ignoring an obvious memory clash does not qualify as bug report.
User avatar
tokra
Vic 20 Scientist
Posts: 1123
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: 32-column 'pet loader' style program

Post by tokra »

Nice one! 32 columns was a common width for HomeComputers (ZX81, ZX Spectrum) and the WideScreen-Ratio looks cool to :)
Mike wrote: Wed Feb 10, 2021 6:34 am When I type in:

Code: Select all

1 PRINT"VIC-20";:GOTO1
RUN
... the screen does not fully scroll, rather the printed stuff 'remains' within a few rows as if in a window. When the program is stopped, the cursor afterwards moves around erratically. That's probably just an oversight somewhere.
This can be fixed with two POKEs:

Code: Select all

POKE 41520,63:POKE 41832,63
I actually had a similar problem with Maxiedit which I discovered only recently while working on another "top-secret" project. Maxiedit only missed one of the values though so the problem manifested not so often. Hint for Victragic: 63 is (2x32-1). Original value in these locations was 87 (4x22-1). Using 95 (3x32-1) will lead to another side-effect but may be ok as well.
User avatar
mathom
Vic 20 Dabbler
Posts: 80
Joined: Wed Aug 07, 2019 11:37 am
Location: Centennial, Colorado
Occupation: Software Engineer

Re: 32-column 'pet loader' style program

Post by mathom »

This is excellent! It is nice to have the full size characters.
...mathom...
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: 32-column 'pet loader' style program

Post by Victragic »

Thanks Mike and Tokra,

I'm not at my computer at the moment but will fix that scrolling issue tonight.

Every issue I had with this project was related to setting and resetting those darn screen row link codes..! I swear I had it working perfectly at some point..

Noizer, when I'm sure this is working correctly, I don't think it would be a hassle to compile a version that loads at $6000.
3^4 is 81.0000001
User avatar
beamrider
Vic 20 Scientist
Posts: 1452
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: 32-column 'pet loader' style program

Post by beamrider »

excellent work!

I find the font to be easy on the eye.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: 32-column 'pet loader' style program

Post by Mike »

Victragic wrote:Noizer, when I'm sure this is working correctly, I don't think it would be a hassle to compile a version that loads at $6000.
As there already exist relocated versions of VICMON at several addresses (and the original is at $6000!), I would count Noizer's request as unwarranted and self-imposed issue.
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: 32-column 'pet loader' style program

Post by Victragic »

Have uploaded a new version updating those line lengths as Tokra identified, I haven't been able to replicate the scrolling problem this time (unless I do something really stupid like try and load it while it is already running!)

Looking at the code in the light of a new day, the main irq routine was pretty darn awful so I've made some improvements which should speed things up considerably. The character data had to be shifted one page forward to accomodate new look-up tables.

Cheers
3^4 is 81.0000001
User avatar
tokra
Vic 20 Scientist
Posts: 1123
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: 32-column 'pet loader' style program

Post by tokra »

Mike wrote: Thu Feb 11, 2021 3:19 am
Victragic wrote:Noizer, when I'm sure this is working correctly, I don't think it would be a hassle to compile a version that loads at $6000.
As there already exist relocated versions of VICMON at several addresses (and the original is at $6000!), I would count Noizer's request as unwarranted and self-imposed issue.
That being said, in my experience such tools/utilities are often in exactly the memory-area you need for another purpose. That's why I offered several compiled versions of Maxiedit for different memory-locations and provided the source as well so anyone could compile it themselves to their desire.

For the area at $a000 it would be fun to have this a a real cart-image with autostart so you can turn on the VIC with the cart attached to the new screen dimensions. The code must not be self-modifying for this though. I tried to make FAT-40/VIC-40 relocatable with this goal, but it self-modifies quite a bit. FAT-40 is pretty fast though!
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: 32-column 'pet loader' style program

Post by Victragic »

tokra wrote: Thu Feb 11, 2021 7:53 am
For the area at $a000 it would be fun to have this a a real cart-image with autostart so you can turn on the VIC with the cart attached to the new screen dimensions. The code must not be self-modifying for this though. I tried to make FAT-40/VIC-40 relocatable with this goal, but it self-modifies quite a bit. FAT-40 is pretty fast though!
My original idea for this was to place the 1k of screen/shadow memory in the 3k Block 0, feeling that this space very rarely gets used for anything on a fully expanded Vic using Basic. This would also mean the screen memory would stay in the same address regardless of where a cart image was..
3^4 is 81.0000001
User avatar
mingle
Vic 20 Dabbler
Posts: 91
Joined: Sun Sep 25, 2016 2:38 am
Location: Melbourne, Australia

Re: 32-column 'pet loader' style program

Post by mingle »

Hi,

I'm trying to get this running in WinVICE (3.5), but am having no luck.

I've tried various RAM config, putting 8K at A000 and another 8K at 2000, but no go.

Any idea on which settings I should look into?

Cheers,

Mike.
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: 32-column 'pet loader' style program

Post by Victragic »

Also as a 'todo', I'm going to write new 'clear screen' and 'scroll' routines to speed things along..

I'll definitely make source available when I'm reasonably happy with where I've taken it.
3^4 is 81.0000001
User avatar
Victragic
Frogger '07
Posts: 605
Joined: Tue Nov 14, 2006 5:56 pm
Location: South Australia

Re: 32-column 'pet loader' style program

Post by Victragic »

mingle wrote: Thu Feb 11, 2021 3:48 pm Hi,

I'm trying to get this running in WinVICE (3.5), but am having no luck.

I've tried various RAM config, putting 8K at A000 and another 8K at 2000, but no go.

Any idea on which settings I should look into?

Cheers,

Mike.
Hi Mike,

RAM at $2000 and $A000 is all you need.

32col.prg needs to be loaded as a program with ',8,1' at the end or it won't load into the correct memory location.

Then sys 40960 to start..
3^4 is 81.0000001
Post Reply