Commodore 128 Alive!

Commodore 128 => 128 programmers => Topic started by: MIRKOSOFT on May 06, 2010, 01:40 AM

Title: If shadow registers of VIC disable...
Post by: MIRKOSOFT on May 06, 2010, 01:40 AM
...it stops KERNAL/Editor VIC-II IRQ.
Disabling with $D8 = $FF and bit 1 of $0A04 will be set on 0
If I'm programming in BASIC commands GRAPHIC, sprite collision, SOUND and PLAY will be disabled, yes?


I don't understand correctly what seems that lightpen collision will be disabled...
Is something more what will be disabled too?


Thanks for every help.


Miro
Title: Re: If shadow registers of VIC disable...
Post by: Hydrophilic on May 06, 2010, 05:05 PM
Unfortunately, the C128 PRG (and other books I've read) do not give a good description of how graphm ($d8) and init_status ($a04) work together to (dis)able ROM features.  So I will try...

First, graphm ($d8), ONLY affects the Editor ROM's interrupt (IRQ) code dealing with VIC video display.  Using BASIC GRAPHIC command changes this value (and others).  Normal values are:
$00 = text
$20 = hi-res bitmap
$60 = split-screen hi-res bitmap
$a0 = multi-color bitmap
$e0 = split-screen multi-color bitmap

Two important things to note:
$80 should logically produce multi-color text, but does not!
$ff will disable VIC changes by Editor IRQ

WARNING: Using GRAPHIC command will ALWAYS change graphm value!  This means if you set graphm to $ff and then use GRAPHIC command, then graphm will NOT be $ff anymore and the Editor IRQ routine will be used again!

So if you want to disable Editor IRQ by graphm = $ff then you must ensure GRAPHIC is never called.

Second, init_status ($a04) has 3 bits that do different things.  For this discussion, we only care about bit 0.  Bit 0 ONLY control's BASIC's interrupt (IRQ) routines, and only if using original (or compatible) KERNAL interrupt routine.

Here is a very simplified overview of KENRAL interrupt routine:(a "normal" IRQ occurs at bottom of VIC screen, split-screen IRQ or non-VIC IRQ are the exceptions)

Anyway, if BASIC ROM interrupt routine ($4006 -> $a84d) is called then the following things happen:
To summarize:Hopefully that answers your question.  Here are some extra thoughts I had. 

When you first turn on C128, BASIC will *normally* setup tables for interrupt (IRQ) processing and set $a04 bit 0.  *normally* means this won't happen if you hold C= key for C64 mode or maybe you have a special cartridge (changes C128 BASIC or forces C64 mode).

If you reset C128 and hold STOP key, you arrive in MONITOR.  In this case the KERNAL has cleared bit 0 of $a04, so BASIC interrupt routine will not work.

Also, BASIC IRQ routine will check a flag, irq_wrap_flag ($12fd), and if the value is not zero then it will exit immediately.  So you can clear bit 0 of $a04 or put non-zero value in $12fd to disable BASIC IRQ.  Clearing bit 0 of $a04 is faster because KERNAL will not call BASIC IRQ at all.

There is another KERNAL flag, hold_off ($a3a), that controls I/O operations.  If this value is set to $ff, then I/O operations (cassette/disk) will not change VIC settings.  Normally the KERNAL will turn off all sprites, set CPU to 1MHz, and (if cassette I/O) blank the VIC screen.  The previous settings will be restored after I/O.  I recommend to NOT change this value to $ff.

I hope I've covered everything...
Title: Re: If shadow registers of VIC disable...
Post by: wte on May 09, 2010, 09:46 AM
Wow, thanks a lot for this comprehensive explanations.

Regards WTE
EhPortal 1.34 © 2025, WebDev